-1

I am a total amateur to javascripts. I have the scripts in this form.

<!-- BEGIN code-->
<script type="text/javascript">a_b='2385y283yf28332';</script>
<script type="text/javascript" src="http://somewebsite.com/jsclients
/jac.js"charset="utf-8"></script>
<!-- END Code -->

Currently, in order for the code to be executed (the code produces a pop up) a click needs to occur on my web page.

I wanted to know, if theres some method which will execute the code when user lands on my website (without clicking anywhere on my site)

Thanks for any help!

2 Answers2

2
<html>
<head>
<script>
function yourFunction()
{
alert("Page loaded!");
}
</script>
</head>
<body onload="yourFunction()">
</body>
</html>

this will sure works fine.try this.

bumbumpaw
  • 2,522
  • 1
  • 24
  • 54
  • so this is correct? ? – user3788696 Jun 30 '14 at 00:29
  • hmm.looks like you want the alerted code from your 2 javascript? try to remove this `` and just change the function on the `onload` part of yours. Call the function which trigger the popup message. – bumbumpaw Jun 30 '14 at 00:35
  • you want the `alert` to show when you `click` on any part of the page? – bumbumpaw Jun 30 '14 at 00:46
  • no, all i want is that code to be executed without getting a click on webpage, currently requires a click on webpage to execute code (that java script, which i dont have access to, seems to monitor the site for a click) – user3788696 Jun 30 '14 at 00:49
  • then `onload` will work. why no access? can you find that `code` on your two js file? is the code coming from here? `http://somewebsite.com/jsclients /jac.js` can you give me the real `url`? – bumbumpaw Jun 30 '14 at 00:58
  • I dnt have access to the fule but real url is "http://ads.juicyads.com/jsclients/jac.js – user3788696 Jun 30 '14 at 01:08
-1

Simply in your javascript you can put

document.onload(function(){
    //DO STUFF HERE
});

And for when your page unloads,

document.unload(function(){
    //DO STUFF HERE
});
itotallyrock
  • 21
  • 2
  • 7
  • Why recommend jQuery, then not use it? You probaby attrated a down vote because you recommended a library that isn't tagged or in the OP. – RobG Jun 30 '14 at 00:29
  • @RobG That too, but mostly the fact that it was recommended and then not even utilised. – Marty Jun 30 '14 at 00:31