Forum Moderators: open

Message Too Old, No Replies

.Net and JavaScript

How to do a Body onLoad?

         

RossWal

4:33 pm on Oct 11, 2002 (gmt 0)

10+ Year Member



I need to fire a javascript off after a .Net page completes it's load. I'm looking at the Page.RegisterStartupScript, but that plops the Javascript in the middle of the HTML. Same for a .Net literal. I s'pose either of these would work, but they don't strike me as being a particularly clean way of accomplishing what I need. I'd rather get it into the body tag as an onLoad event. Any thoughts appreciated!

My script will open a new window and set the focus there. Wondering to myself as I ramble...will the browser render the HTML that follows the script that bounces out of the page, or will it executed the javascript as in encounters it in the html stream? Hmmm, off to find out.

Thanks,
Ross

RossWal

9:09 pm on Oct 11, 2002 (gmt 0)

10+ Year Member



Here's an update if anyone's interested. I found that the window.open did work when invoked from within the html stream, but it was waaaaaay sloooow. It was as though it was waiting for the page to timeout or something. So, to hack around that I created the following code:


var gotoURL='Stop'
function openWindowNoNav() {
if (gotoURL != 'Stop') {
popupWin = window.open(gotoURL,'alphonse', 'menubar=0,scrollbars=1,location=0,
toolbar=0,resizable=1,status=1,
width='+(screen.width * .9)+',height='+(screen.height * .9)+',left=40,top=40')
popupWin.focus()
}

openWindowNoNav gets called from the onload for the body. gotoURL gets set to something meaningful by the Page.RegisterStartupScript, otheerwise it halts the window.open. Cludgey to say the least. But it works. Improvement ideas most welcome.