Two pages on main window?

Hello there,

I have window with a logo of the company, and if people click on the logo a seperate window opens up _blank (no problems so far…)

but if the visitors close the second window, and come back to the main window (1st page) i want a message to displayed that is saying
(thank you for visiting blablabla.com)

how can i do this in html?

Thanx,

Andreas:cowboy:

do you want it displayed on the first window or on the second window before it closes, or in a pop up window, or in an alert box.

it may well be javascript.

if you want it in the first window, You could try naming the first window, create a new HTML page saying “thank you bla bla” then use <a href=“new window” target = “window name”>

This is only if memory serves me correctly. I can’t seem to find the script I wrote for this. Maybe I deleted it… who knows… I know believe this method only works in IE…

In between the head tags of your HTML page add this…

<SCRIPT LANGUAGE="JavaScript">
<!--
function alertMe() {
alert('Thank you for visiting!');
}
-->
</SCRIPT>

Now inside your body tag is where you define what happens.

<BODY onBeforeunload = "alertMe()">

Ok, so this is an alert I know, but it is much easier to test with alert. Actually wait, I didn’t test this… I guess I should…haha.

Ok Ok, I got bored and I started advancing some more on this. This next up is if you want an html page pop up window to appear…

In between the head tags of your html page add this…

<SCRIPT LANGUAGE="JavaScript">
<!--
function exitThanks(page,winName,w,h,scrollb,resize) {
var win=null;
centerWidth = (screen.width) ? (screen.width-w)/2 : 0;
centerHeight = (screen.height) ? (screen.height-h)/2 : 0;
config =
'height='+h+',width='+w+',top='+centerHeight+',left='+centerWidth+',scrollbars='+scrollb+',resizable='+resize+''
win = window.open(page,winName,config);
}
-->
</SCRIPT>

Now add to your body tag…

<BODY onBeforeUnload = "exitThanks('http://www.lostinbeta.com', 'exitThanks', '300', '300', '1', '0')">

Tah Dah, instant exit window. I even tested it this time (by the way, my last way worked too:)) Oh yeah, and this one automatically centers the pop-up no matter what monitor size.

Maybe I should explain also…

In the body tag with the onBeforeUnload command…

This first thing is the URL of the page you want loaded, the exitThanks is the window name, the 300 is the width and the 2nd 300 is the height. the 1 means true for scrolling (set to 0 if you don’t want scrolling) and the 0 at the end is to disable resizing the window (if you want the window resizeable just make that a 1)

I hope this helps you out=) Remember, this is IE specific, sorry but Netscape sucks and scripting is about 1million times harder to learn in Netscape so I never bothered with it.

Yay, memory served me correctly…woo hoo:P

Ok, and I reread your question and I think I just did all that for nothing. It seems I misunderstood your question and what you really want is for your main window to change and not a pop-up window.

Crap:-\ Sometimes it hurts being this stupid :stuck_out_tongue:

Sorry… hmmm, maybe I will see what I can do with the other way…

OK OK OK!!! I DID IT. I think I finally actually did what you wanted…

First, create the page that will contain your logo image.

Between your head tag add this code…

<SCRIPT LANGUAGE="JavaScript">
<!--
function openWin(page,winName,w,h,scrollb,resize) {
var win=null;
centerWidth = (screen.width) ? (screen.width-w)/2 : 0;
centerHeight = (screen.height) ? (screen.height-h)/2 : 0;
config ='height='+h+',width='+w+',top='+centerHeight+',left='+centerWidth+',scrollbars='+scrollb+',resizable='+resize+''
win = window.open(page,winName,config);
win.creator=self
}
-->
</SCRIPT>

Now on your logo image add these actions (ok, I am using a button for easy, you should know where to put the code on the image though). I explained how this works in a previous post.

<input type="button" value="Open Window" onClick="openWin('content.html', 'exitThanks', '300', '300', '1', '0')">

Alright so we got all the functions done on that page. Now create a page called “content.html”. Between the head tags add this code…

<SCRIPT LANGUAGE="JavaScript">
<!--
function exitThanks(url){
window.opener.location=url
}
//-->
</SCRIPT>

Now change the body tag by adding stuff. Like this…

<BODY onBeforeUnload="exitThanks('http://www.lostinbeta.com')">

There, now when you close the window, it will load my site in your main window:) And now you have 3 different ways of doing the same thing. Sheesh, I hope at least one of these is what you wanted!!!

Sorry for messing up so much. I paid with it in trying to figure out this last method, sheesh, took me quite a while and it was just simple coding.

Good Luck and I hope it helps. I attached a .zip file with 2 .html files in it that show you my example of it that works. So if for any reason it doesn’t work for you, you can compare it.