Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

automattically start pop up window 1

Status
Not open for further replies.

Boomerang

Programmer
Mar 30, 2001
766
NL
Hi there,

My site starts with "default.asp" This page contains a frameset with 3 frames left, top and main. The mainframe is used for the further page-navigation.

Now I want to use the javascript window.open function to start automattically a pop up window. This pop up window may only start up once per session. So I thought to do that in the session_onstart handler in the global.asa

But I don't know the syntax to start automatticcaly a javasript function.

Or are there better ways?
(I read something in MS interdev help that noncookie browser does not return the SessionID cookie, so the server creates a new session each time the user requests a page. So that for each request, the server processes the Session_OnStart.)
Does this has effect when users navigate to other pages in my frameset?

A lot of questions right!

Please help,
Erik
 
You are correct about the cookie & session thing. And the bad thing is that I don't know of a way to make it only appear on the first load without the use of session variables. It really is a shame that people use cookies for privacy invasion and cause many users to turn them off. It really limits what we can do and the experience we can deliver to our users. But, that's the way the ole pickle squirts.

---------------------

To implement this, I would probably just set a session variable to 1 on the popup window, and then check that value on each load of the main page. If it's 1, then don't open the window. If it's not, then do.

code for the popup window --
<%session(&quot;loaded&quot;) = 1%>

code for the main window
<body <%if session(&quot;loaded&quot;) = 1 then response.write(&quot;onLoad=&quot;&quot;window.open('&quot; & &quot;popUp.asp & &quot;','&quot; & &quot;popup & &quot;');&quot;&quot;&quot;) end if%>>

So that the javascript onLoad event is rendered to the browser and then fired if the session variable has not yet been set -- once the popup opens, it sets the variable, and all is right with the world.

good luck! :)
Paul Prewett
penny.gif
penny.gif
 
Hi Paul, Thanks for answering!

After some puzzling it works, I think you ment <> 1 and I puzzled a long time with the quotes. I'm not [yet :)] such an experienced VB programmer).

But I don't understand some things.

1) I started with this code:

<body <%call PopUp()%>

function PopUp()
if session(&quot;loaded&quot;) <> 1 then
Response.Write(&quot;onLoad=&quot;&quot;window.open('&quot; & &quot;../homepage/popup_vac.asp&quot; & &quot;',' popup_vac');&quot;&quot;&quot;)
end if
end function

The code <%session(&quot;loaded&quot;) = 1%> in popup_vac doesn't work! I don't know why, I tried a lot. Is that because you do a response.write and not actualy call the page with response.redirect?

So I set the session(&quot;loaded&quot;) right after the response.write

2) I'm still curious if there is a way to start automattically javascript in an &quot;asp source&quot; without using onload, onclick etc.

Erik



 
Sorry Paul the code herefore was the wrong copy, this is what I made:


function PopUp()
if session(&quot;loaded&quot;) <> 1 then
Response.Write(&quot;onLoad=&quot;&quot;window.open('../homepage/popup_vac.asp','popup_vac');&quot;&quot;&quot;)
session(&quot;loaded&quot;) = 1
end if
end function

Erik
 
Sorry bout that =1 -- my bad. :)

You can automatically run any javascript by just saying:

<script language=javascript>
anyValidJavaScriptStatement;
</script>

So that you don't abstract it into a function, but simply state it &quot;inline&quot; so that when the browser encounters it, it executes it.

Not sure why the popup can't set the session variable, but setting it in your main page is probably better, anyway.

:)
Paul Prewett
penny.gif
penny.gif
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top