Click to See Complete Forum and Search --> : A question on popups
aommaster
12-03-2003, 12:58 AM
How do i do the following:
When the page loads, i want a popup to come asking if i want to set the page as a homepage. i know this is annying, but i am doing it for a javascript section in my website. Please help.
This is the site
www.dragonslair.co.nr
Pittimann
12-03-2003, 02:13 AM
Hi!
Please go here to check out some code for your "user's homepage stuff" if you don't know how to do that:
http://javascript.internet.com/page-details/set-homepage-link.html
As far as your popup is concerned, have a look at this:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Untitled</title>
<script type="text/javascript">
function openwin() {
var wintitle = "popup"; // popup title
var width = "400"; // popup width
var height = "250"; // popup height
LeftPosition = (screen.width) ? (screen.width-width)/2 : 0;
TopPosition = (screen.height) ? (screen.height-height)/2 : 0;
windowproperties =
'height='+height+',width='+width+',top='+TopPosition+',left='+LeftPosition+',scrollbars=no';
newwin = window.open('', wintitle, windowproperties);
newwin.document.write('<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"><html><head><title>'+wintitle+'</title></head><body><center>Put your link for setting your page as the homepage of the user here...<br><br><a href="javascript:window.close();" title=" Close this window... ">click here to close window</a></center></body></html>');
}
</script>
</head>
<body onload="openwin()">
Your page's content...</body>
</html>
Cheers - Pit
aommaster
12-03-2003, 02:18 AM
I think u understood me wrong.
This is how i wanted it to be. I want it so that as the page loads, an alert box asking to set the homepage to this site. The link u have given me shows me how to set the homepage using a link (which i already know how to use). Now, using this code, i want it so that, immediately after the page loads, this come up automatically.
Thanx
Pittimann
12-03-2003, 02:28 AM
Sorry - but you've asked for a popup and I gave you one! You didn't ask for an alert and plus: a simple "alert box" is not able to give the user any choice. It just contains an OK button.
Seems you misunderstood my code - if you don't want a popup window you need a "confirm box".
If you told me what you actually want I'll post another code here, but the one I already posted should be sufficient for you.
In the document.write of the function, you just have to replace the sentence "Put your link for setting your page as the homepage of the user here..." with your link.
I just put the link at the beginning of my last post, INCASE you do not know, how to accomplish that part...
Cheers - Pit
aommaster
12-03-2003, 02:32 AM
sorry about that. I better explain it to you in a little more detail so u dont trouble urself.
Ok, you know the set as homepage prompt. The one that asks you whether you want to set this page as ur homepage.
I want this to come up right after the page loads, without anyone clicking a link
Thanx for ur help
Pittimann
12-03-2003, 02:47 AM
I'm not troubling myself :cool:!
So you are talking about the confirm box with "yes" and "no" (maybe: "OK" and "Cancel" in English - I don't know).
As you asked for a popup (in your post itself and its' subject), I was convinced, that you want a more individual solution than the confirm box.
In whatever way you handle the thing:
A user who wants to set your page as homepage has to click something ("yes" or "ok" in the confirm box or the link I proposed in the popup).
Somebody who doesn't want that has to click "no" or "cancel" in the confirm box or close the popup.
One click for everybody - however you solve it. So what's bad about the popup I gave you???
Cheers - Pit
aommaster
12-03-2003, 07:07 AM
Now u have understood me. U r talking about exactly what i wanted.
Actually, i know that it is quite an easy way to set as a homepage, but i just wanted it for the knowledge. I just wanted it so that i could see how poeple actually do it.
Do u actually know how to do it? Just out of curiosity.
Pittimann
12-03-2003, 07:57 AM
Just to satisfy your curiosity - I know how to do it.
I was about to write something a bit sarcastic - I'll just leave it out.
Well, to come to the point: the box you're talking about is IE specific.
It would be possible, to inform non IE users how to set your page as their homepage -
i'll leave that up to you. Frankly speaking, I hate pages popping up that stuff.
If I want to make a page my homepage I can do that myself -
no need for **** popping up (sorry - do not want to insult you!).
I just prefer going to some page and read content, look at graphics, download something etc.,
but not be disturbed by having to click away popups or boxes!
Here's the code:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Untitled</title>
<script language="JavaScript" type="text/javascript">
<!--
function homePage(){
if (document.all){
document.body.style.behavior='url(#default#homepage)';
document.body.setHomePage('http://www.YourWebSiteHere.com');
}
}
//-->
</script>
</head>
<body onload="javascript:homePage()">
</body>
</html>
Cheers - Pit
aommaster
12-04-2003, 01:29 AM
Thanx alot. Actually, to be honest, i also hate this sort of stuff. I actually just did it for the knowledge. Thanx alot again.
Pittimann
12-04-2003, 01:36 AM
You're welcome!! ;)
aommaster
12-04-2003, 02:03 AM
This is really wierd.
I tried to use it as a test, but it says there is a runtime error.
Why is that happening???
Pittimann
12-04-2003, 02:11 AM
No idea! It should work fine in IE.
But one thing - in the line:
<body onload="java script:homePage()">
you have to delete the space between "java" and "script" (it is automatically inserted when posting that word...).
Cheers - Pit
aommaster
12-04-2003, 02:14 AM
Ok it works. That was the reason. And one more thing,
UR A GENIUS!! Thanx alot