I've had this Javascript code on my web site for years and it worked. It is written to help filter out email spam bots;
<script type="text/javascript">
emailserver = "website.com" emailE = "Maria#" + emailserver document.write("<A href=" + "'mailto:" + emailE + "'>" + emailE + "</a>")
</script>
It hasn't worked for a while. Can anyone tell me what changed so that this no longer works? Thanks.
Works fine. You just forgot about semicolons ;.
By the way, you don't need the quotation marks " in the last line of your code (in the document.write() function).
emailserver = "website.com";
emailE = "Maria#" + emailserver;
document.write("" + emailE + "")
Related
I want to get the HTML code of a webpage after it has been modified (similar to one that we see in inspect element tab of a browser) and I want to do it programatically (if possible using python or any other programming language). Can someone suggest how I might be able to proceed with this? I know its possible since browsers are able to do it.
As the server has no access to client window after client-side changes, you have to use client side languages.
In jquery:
var fullCode= "<html>" + $("html").html() + "</html>";
if you want also to include the Doctype:
var node = document.doctype;
var fullCode = "<!DOCTYPE "
+ node.name
+ (node.publicId ? ' PUBLIC "' + node.publicId + '"' : '')
+ (!node.publicId && node.systemId ? ' SYSTEM' : '')
+ (node.systemId ? ' "' + node.systemId + '"' : '')
+ '>';
fullcode += "<html>" + $("html").html() + "</html>";
Thanks to this
Using JQuery you can achieve this by the following code
$(document).ready(function(){
var html = "<html>"+$('html').html()+"</html>";
});
I'd like to display some HTML elements under my game on Facebook. Specifically, an image with a link to a website, but that's not the point of the question.
I understand what is required, and have successfully used the Application.ExternalEval() method, and the sample JS string provided by Facebook, to add some HTML text on top of the game itself.
I am following the information found on this page.
I have attempted the following permutations:
"var insertionPoint = body.children[0]; " + "body.insertBefore(headerElement, insertionPoint);";
"var insertionPoint = body.children[0]; " + "body.insertBefore(headerElement, insertionPoint.nextSibling);";
"var insertionPoint = body.children[1]; " + "body.insertBefore(headerElement, insertionPoint);";
After a couple of hours of frustrating trial and error, I have been unable to produce working JS injection code to display HTML immediately below the game itself on the canvas. Can someone help?
I've been trying to do the same frustrating thing for a minute, here's what I've arrived at, had to use different techniques for different browsers.
string injection = "if(navigator.userAgent.indexOf(\"Firefox\") >= 0){;" +
"var headerElement = document.createElement('div');" +
"headerElement.innerHTML = '<img src=\"URLTOSOURCE" style=\"width: 100%; text-align: center\" />';" +
"var body = document.getElementsByTagName('body')[0];" +
"var insertionPoint = body.lastChild;" +
"body.insertBefore(headerElement, insertionPoint);" +
"}else{;" +
"var headerElement = document.createElement('div');" +
"headerElement.innerHTML = '<img src=\"URLTOSOURCE" />';" +
"var body = document.getElementsByTagName('body')[0];" +
"var insertionPoint = body.children[0]; " +
"var unityPlayer = document.getElementById('unityPlayerEmbed');" +
"unityPlayer.parentNode.insertBefore(headerElement, unityPlayer.nextSibling);" +
"var embedTag = unityPlayer.getElementsByTagName('embed');" +
"embedTag[0].setAttribute('style','display:block;width:1200px;height:600px');" +
"};";
Application.ExternalEval(injection);
This should do the trick!
"var insertionPoint = body.lastChild;"
I post tricks and tutorials on my blog, check it out also for facebook sdk tutorials!
blog.bigfootgaming.net
I am trying to create email templates just using an html file. This file will display a list of mailto links that, when clicked, will open a template with message. I got it working for the most part but some of these templates use prompts to add information to the message before creating it. The problem is that it doesn't seem to work right. Here is my code.
function sendReport(emailName, addresseList){
document.writeln('<a onClick="setPrompt(this,\'' + addresseList + '\')" href="mailto:' + addresseList + '?subject=' + 'Report' + '&body=' + 'Here is the report.' + '">' + emailName + '</a><br />');
}
function setPrompt(obj, addresseList){
var reportName = prompt("Report name","");
obj.attr('href', ='mailto:' + addresseList + '?subject=' + reportName + '&body=' + "Here is the report."); //<-- this is the line that is giving me trouble.
}
You have a typo in the last line and there is no .attr() built in function in Javascript. This should fix it:
obj.setAttribute('href', 'mailto:' + addresseList + '?subject=' + reportName + '&body=' + "Here is the report.");
I'm using JSPs to create dynamic web pages...
At the beginning of one of my forms, I have some javascript that needs to run to initialize the page with given attributes.
I'm creating a Java String in the JSP <% %> blocks that I want to pass to the initializePage javascript function.
Here's the code:
<script>
$(document).ready(function(){
<%String algorithmXMLPath = request.getContextPath() + "/" + PePw.PATH_ALGORITHM_XMLS;
String initParms = "'" + algorithmXMLPath + "'," +
" '" + Utilities.getString(reqBean.getMachineType()) + "'," +
" '" + Utilities.getString(reqBean.getModel()) + "'," +
" '" + Utilities.getString(reqBean.getReasonCode()) + "'";%>
initializePage(<%=initParms%>);
});
</script>
This results in a source code of:
initializePage('/PePasswords/data/algorithmXMLs/', '', '', '');
When I run this, I get an error in the FF error console "Unterminated String literal" and it points to the end of the initializePage call... When I click the link in the error console, it actually points to the line with });
Not sure what i'm doing wrong here...
Looks like one of the variables had a hidden new line "\n" being passed into the JSP call...
I replaced
Utilities.getString(reqBean.getReasonCode())
with
Utilities.getString(reqBean.getReasonCode()).replace("\n", "").trim()
I've been developing a web game, with jquery doing some of the work. It was on a server, but I've moved it back to my laptop. Everything seems to work fine, except the most important function, which imports the contents of an html file.
$(".ReportList a").live('click', function(){
var getreportname = $(this).text();
$("#scroller").append("<span>The reportname is " + getreportname + "</span>");
var usersreport = "ReportList_" + User + "";
jQuery.get('Reports/' + getreportname + '.html', function (data) {
$("#" + usersreport).html(data);
$("#" + usersreport + " span").addClass("Py" + User);
updateCount();
});
});
Not sure why it stopped working. Would appreciate any insight.
I didn't need the .get() method to do what I wanted, .html() was good enough if I re-formulated the script.