 |
| Javascript General Javascript discussions. |
Welcome to the p2p.wrox.com Forums.
You are currently viewing the Javascript section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
|
|
|
|

April 27th, 2004, 05:57 AM
|
|
Friend of Wrox
|
|
Join Date: Jun 2003
Posts: 347
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
body tag in an include page
Hi there
I need to use an OnLoad command on the body tag in an include page; however, if I use a body tag in my include page the whole page messes up. Is there any other tag I can use the OnLoad command on other than the body tag?
thanks
Adam
|
|

April 27th, 2004, 08:21 AM
|
|
Friend of Wrox
|
|
Join Date: Jul 2003
Posts: 683
Thanks: 0
Thanked 1 Time in 1 Post
|
|
Hi Adam,
What sort of include page are you using - external javascript, asp, other... ?
Best regards,
Chris
|
|

April 27th, 2004, 09:37 AM
|
|
Friend of Wrox
|
|
Join Date: Nov 2003
Posts: 1,285
Thanks: 0
Thanked 2 Times in 2 Posts
|
|
I would embed the included page in an iframe, were I you.
HTH,
Snib
<><
|
|

April 27th, 2004, 10:17 AM
|
|
Friend of Wrox
|
|
Join Date: Jun 2003
Posts: 347
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
it's an asp page that I'm including
|
|

April 27th, 2004, 10:21 AM
|
|
Friend of Wrox
|
|
Join Date: Nov 2003
Posts: 1,285
Thanks: 0
Thanked 2 Times in 2 Posts
|
|
Personally I never include a page unless it's absolutely necessary because 1) your stylesheets and scripts apply to the included page 2) the included page's scripts and stylesheets are applied to your page and 3) the body and sometimes other tags coexist and conflict (your problem).
I would, like I said in my previous post, use an iframe.
HTH,
Snib
<><
|
|

April 27th, 2004, 10:31 AM
|
|
Friend of Wrox
|
|
Join Date: Jun 2003
Posts: 347
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
OK, thanks Snib
|
|

April 27th, 2004, 10:33 AM
|
|
Friend of Wrox
|
|
Join Date: Jul 2003
Posts: 683
Thanks: 0
Thanked 1 Time in 1 Post
|
|
If you are not already using the onload event, you can just add a script block to the page, something like...
<script type="text/javascript">
window.onload = myFunction;
function myFunction(){
// do some stuff here
}
</script>
If you are already using the onload event, you could add additional event listeners using window.attachEvent for IE & window.addEventListener for Mozilla.
bfn,
Chris
|
|

April 28th, 2004, 03:53 PM
|
|
Friend of Wrox
|
|
Join Date: Jun 2003
Posts: 347
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Hi Chris
Can you see why this is not working? There's no error but it doesn't seem to randomize my images.
thanks
Adam
<script language="javascript">
window.onLoad = choosePic;
Pix = new Array("image_bin/lpe_top_banner.jpg","image_bin/topbanner2.jpg","image_bin/topbanner3.jpg","image_bin/topbanner4.jpg")
imgCt = Pix.length
function choosePic() {
if (document.images) {
randomNum = Math.floor((Math.random() * imgCt))
document.pic.src = Pix[randomNum]
}
}
</script>
<table width="100%" height="113" border="0" cellpadding="0" cellspacing="0">
<tr>
<td width="874" height="113" valign="top" background="image_bin/lpe_top_banner.jpg" name="pic">
|
|

April 29th, 2004, 03:03 AM
|
|
Friend of Wrox
|
|
Join Date: Jul 2003
Posts: 683
Thanks: 0
Thanked 1 Time in 1 Post
|
|
Hi Adam,
It's case sensitivity, you need window.onload, not window.onLoad.
Cheers,
Chris
|
|
 |