Is it possible to do somthing like this ?
<script type='text/javascript' src='xxx.js'>
alert('Can I say hello in this area?');
</script>
Thanks.
Is it possible to do somthing like this ?
<script type='text/javascript' src='xxx.js'>
alert('Can I say hello in this area?');
</script>
Thanks.
No, but it is possible to do this:
<script type='text/javascript' src='xxx.js'>
alert('Can I say hello in this area?');
</script>
<script type='text/javascript'>
eval([].pop.call(document.getElementsByTagName('script')).innerHTML);
</script>
It eval's the .innerHTML of the last script tag that was closed.
It is also possible to include the eval code in your external file, the last script tag should evaluate to the script tag that initialized the file download.
Nope.
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.5.1/jquery.min.js">
var doesItWork = "#myElement";
</script>
<script type="text/javascript">
$(document).ready(function() {
alert("did it work?");
$(doesItWork).text("yes");
});
</script>
<div id="myElement">no</div>