|
|
How To Create A Popup Window With Javascript? | ||
Discussion by soleimanian with 21 Replies.
Last Update: December 18, 2009, 3:16 pm (View Latest) | Page 1 of 2 pages. | ||
I want to in popup massage suggest to visitors of my site to make my site their home page .
Please note that I have some script code that visitors most click on a text to make my site their home page .
Every one that can help me please send an email to soleimanian@noavar.com
Sun Sep 5, 2004 Reply New Discussion
http://www.berm.co.nz/popupmaker/.
Or you may want to download this free software that can help you make pop-ups:
http://www.codelifter.com/pop5index.html.
Either way simply follow the instructions and you can get your pop-up very quickly.
Mon Sep 6, 2004 Reply New Discussion
or you can use a the <body onload="..."> event.
Mon Sep 6, 2004 Reply New Discussion
CODE
<body onload="popup()">The above code calls the function from the Javascript file or if you have it embedded in the webpages. The below code is what you need to open the page in the popup, this can be pasted into an external file which contains all the javascript or embedded as i said previously.
CODE
function popup() {window.open("popuppage.html","Homepage","resizable=no,status=yes,scrollbars=yes,width=260,height=500");
}
If you require any help or do not understand then ask
Tue Sep 7, 2004 Reply New Discussion
Sun Sep 12, 2004 Reply New Discussion
Sun Sep 12, 2004 Reply New Discussion
I would rahter just make a link that says "add this page to your favorites list!" or something like that.
Sun Sep 12, 2004 Reply New Discussion
I will dig for the js code to do it.
Mon Sep 13, 2004 Reply New Discussion
Will pop up dialog box asking if you would like to set http://www.yoursitehere.com as your homepage.
There is no standard so there are very few browsers it will work in.
I don't think NS has ever had support.
IE5 supported it but I am not sure if the syntax was the same.
Mon Sep 13, 2004 Reply New Discussion
<a href="java script:" onClick="window.external.AddFavorite(location.href, document.title);">add to favorites</a>
Mon Sep 13, 2004 Reply New Discussion
CODE
function popUp() {
alert("Please make my site your homepage!");
}
You just put the code above together with your other script code in the <script> tag -- that is within the <head> tag. How it works is that the "alert" function will pop up as an alert box and whatever message you want your site visitors to see first when they get to your site will be displayed in small pop-up window (AKA the alert box). In between the quotations within the parenthesis is what will appear in the alert box. I just put "Please make my site your homepage!" as an example but you can change that part of the message to whatever you want it to be.
And now, in the body tag, have the following:
CODE
<body onload="popUp()">
This code is as oveture explains. It will call the function called (well, in this case) "popUp()" and "onload" (which means that when your webpage loads), the function being called will be executed. So... if you don't have the "onload" function in the <body> tag, the script from how to pop-up a window will not work.
Okay, I hope that helps you out. A really simply code and I believe it fits what you are asking for. ^__^
Regards,
-- scryoko
Wed Jan 11, 2006 Reply New Discussion
For example, if you want to have a pop-up on a page when someone enters it, use this code:
CODE
<script language="JavaScript type="text/javascript"">alert("Place your message here!")</SCRIPT>Or you can get one that pops up when someone leaves the page:
CODE
<body onunload="alert('Place your message here!');">Also, there is one when a visitor moves their pointer over a link:
CODE
<a href=""onMouseover="alert('Place your message here!')">Put the text you want to be visible here.</a>Or if you want something more cool, make one that says the time and date upon entering a page:
CODE
<script language="JavaScript" type="text/javascript">document.write("Having a great day?")
document.write("<BR>")
document.write("Today's date is ",Date())
</script>
Finally, you could use one that comes up when you enter and leave a page.
CODE
<body onload="alert('Place your message here!');"onunload="alert('Place your second message here!');">
Sun Feb 12, 2006 Reply New Discussion
CODE
if(!isAdded) { // use a var from a cookie to check wether your site is already added to favorites
if(question("Do you want to make my site your homepage") { // Ask to add this site
window.external.AddFavorite(location.href, document.title);
}
}
I'm almost sure this isn't correct javascript and I don't know how to use cookies, so plz rewrite this code, but isn't this a nice idea instead of the popup?
-=jeroen=-
Tue Feb 14, 2006 Reply New Discussion
NEVER EVER EVER EVER HAVE POP-UPS ON YOUR SITE TO ASK PEOPLE TO DO SOMETHING.
If they want to make your site part of their favourites, then they will do. If they want to make it their home page, then they will do. If they don't have the technical knowledge, then use simple inline javascript as well as a link to achieve the effect.
It is possible to create in document pop-ups, using AJAX, but I aint telling you how, as I do not know myself.
Tue Feb 14, 2006 Reply New Discussion
-Badi
Wed Sep 26, 2007 Reply New Discussion
Javascript Javascript (8)
|
(5) Javascript sources Links to online javascript resources
|
Index




