Say you have a simple ajax request like $("#container").load('/url #content');
. The loaded DOM will be something like
<a>email</a>
<script>/* some script */</script>
What can I do to get the contents of the script tags to execute?
Cloudflare automatically protects email addresses in the DOM by replacing the text with [email protected]
and including a script that unravels it. However, the contents can be loaded asynchronously and the script that does the unraveling won't be executed. I could just turn off the email protection feature (I think) but I'm wondering if there's another way around this.
See it in action at http://aysites.com/what -- click "Contact"
The “script” tag JavaScript programs can be inserted almost anywhere into an HTML document using the <script> tag. You can run the example by clicking the “Play” button in the right-top corner of the box above. The <script> tag contains JavaScript code which is automatically executed when the browser processes the tag.
AJAX is not a programming language. AJAX just uses a combination of: A browser built-in XMLHttpRequest object (to request data from a web server) JavaScript and HTML DOM (to display or use the data)
You can add <script></script> inside a DIV tag. Just check on w3c, it is valid HTML.
How AJAX Calls Work. AJAX uses both a browser built-in XMLHttpRequest object to get data from the web server and JavaScript and HTML DOM to display that content to the user. Despite the name “AJAX” these calls can also transport data as plain text or JSON instead of XML.
There is a pure js function which invokes the JavaScript compiler. It's eval
. You need to use it.
Examples:
jQuery.globalEval("var newVar = true;")
on jQuery.com
Or
eval("x=10;y=20;document.write(x*y)");
document.write("<br />" + eval("2+2"));
document.write("<br />" + eval(x+17));
on w3schools
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With