Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Web Programming > JavaScript > Javascript
|
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
 
Old April 27th, 2004, 05:57 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 347
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to Adam H-W
Default 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
 
Old April 27th, 2004, 08:21 AM
Friend of Wrox
 
Join Date: Jul 2003
Posts: 683
Thanks: 0
Thanked 1 Time in 1 Post
Default

Hi Adam,

What sort of include page are you using - external javascript, asp, other... ?

Best regards,

Chris

 
Old April 27th, 2004, 09:37 AM
Friend of Wrox
 
Join Date: Nov 2003
Posts: 1,285
Thanks: 0
Thanked 2 Times in 2 Posts
Default

I would embed the included page in an iframe, were I you.

HTH,

Snib

<><
 
Old April 27th, 2004, 10:17 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 347
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to Adam H-W
Default

it's an asp page that I'm including
 
Old April 27th, 2004, 10:21 AM
Friend of Wrox
 
Join Date: Nov 2003
Posts: 1,285
Thanks: 0
Thanked 2 Times in 2 Posts
Default

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

<><
 
Old April 27th, 2004, 10:31 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 347
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to Adam H-W
Default

OK, thanks Snib
 
Old April 27th, 2004, 10:33 AM
Friend of Wrox
 
Join Date: Jul 2003
Posts: 683
Thanks: 0
Thanked 1 Time in 1 Post
Default

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

 
Old April 28th, 2004, 03:53 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 347
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to Adam H-W
Default

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">
 
Old April 29th, 2004, 03:03 AM
Friend of Wrox
 
Join Date: Jul 2003
Posts: 683
Thanks: 0
Thanked 1 Time in 1 Post
Default

Hi Adam,

It's case sensitivity, you need window.onload, not window.onLoad.

Cheers,

Chris






Similar Threads
Thread Thread Starter Forum Replies Last Post
Set Selected Text inside of page body caseym Javascript How-To 0 April 9th, 2008 03:17 PM
Master Page Body Element Properties SomeoneKnows BOOK: Wrox's ASP.NET 2.0 Visual Web Developer 2005 Express Edition Starter ISBN: 978-0-7645-8807-5 0 August 10th, 2007 04:13 PM
Properties in Body Tag - Pg. 40/41 jabs BOOK: Wrox's ASP.NET 2.0 Visual Web Developer 2005 Express Edition Starter ISBN: 978-0-7645-8807-5 1 December 5th, 2006 09:12 AM
HTML tag vs Body Tag CFGerry BOOK: Beginning CSS: Cascading Style Sheets for Web Design ISBN: 978-0-7645-7642-3 1 October 7th, 2005 07:13 AM
Evaluating body content of a custom tag Tag Librarian Pro JSP 0 May 13th, 2005 02:40 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.