Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Web Programming > JavaScript > Javascript
Password Reminder
Register
Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
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 tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developersí questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Display Modes
  #1 (permalink)  
Old April 27th, 2004, 05:57 AM
Friend of Wrox
 
Join Date: Jun 2003
Location: , , .
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
Reply With Quote
  #2 (permalink)  
Old April 27th, 2004, 08:21 AM
Friend of Wrox
 
Join Date: Jul 2003
Location: , , United Kingdom.
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

Reply With Quote
  #3 (permalink)  
Old April 27th, 2004, 09:37 AM
Friend of Wrox
 
Join Date: Nov 2003
Location: , , .
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

<><
Reply With Quote
  #4 (permalink)  
Old April 27th, 2004, 10:17 AM
Friend of Wrox
 
Join Date: Jun 2003
Location: , , .
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
Reply With Quote
  #5 (permalink)  
Old April 27th, 2004, 10:21 AM
Friend of Wrox
 
Join Date: Nov 2003
Location: , , .
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

<><
Reply With Quote
  #6 (permalink)  
Old April 27th, 2004, 10:31 AM
Friend of Wrox
 
Join Date: Jun 2003
Location: , , .
Posts: 347
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to Adam H-W
Default

OK, thanks Snib
Reply With Quote
  #7 (permalink)  
Old April 27th, 2004, 10:33 AM
Friend of Wrox
 
Join Date: Jul 2003
Location: , , United Kingdom.
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

Reply With Quote
  #8 (permalink)  
Old April 28th, 2004, 03:53 PM
Friend of Wrox
 
Join Date: Jun 2003
Location: , , .
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">
Reply With Quote
  #9 (permalink)  
Old April 29th, 2004, 03:03 AM
Friend of Wrox
 
Join Date: Jul 2003
Location: , , United Kingdom.
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

Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

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 08: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



All times are GMT -4. The time now is 05:33 AM.


Powered by vBulletin®
Copyright ©2000 - 2018, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.