bookmark - How To Create A Popup Window With Javascript?

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.
bookmark - How To Create A Popup Window With Javascript?  
    
free web hosting
 
Please help me!
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   


You can try this free online pop-up maker:
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   

I recomand you to use a javascript. You can find free scripts at http://javascript.internet.com
or you can use a the <body onload="..."> event.

Mon Sep 6, 2004    Reply    New Discussion   

as wappi suggested you can use the onload="" in the BODY tag and then call the function from the javascript file to load, something like this:

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   


sorry, i'd actually recommend not using popups to display your welcome message because nowadays everyone is using some sort of popup blocker or have installed SP2.

Sun Sep 12, 2004    Reply    New Discussion   

i have to agree but some people have to learn these things by trial and error. People have to try new things and then get feed back on what is good or what might drive people away from their site. And having a pop-up which instantly loads the moment the page is opened is not a good idea, only for the reason that everyone will instantly close it, whether it contained important information or not. It is best to just have a text link saying 'make this your homepage'.

Sun Sep 12, 2004    Reply    New Discussion   

I'll have to agree with dissipate and overture. It does not make a site very attractive to the user if you do that. Why? its annoying and most other websites that are ... not so good sites like they promote spyware and adware use those kinds of schemes.
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 think he wants to know the code to pop up the yes/no dialog box asking the user if he would like to set his page as there start/home page.

I will dig for the js code to do it.

Mon Sep 13, 2004    Reply    New Discussion   

<body STYLE="behavior:url('#default#homePage')" ID=sID onLoad="sID.setHomePage('http://www.yoursitehere.com')">

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   

Here is code to make a link to add current page to favorites:
<a href="java script:" onClick="window.external.AddFavorite(location.href, document.title);">add to favorites</a>

Mon Sep 13, 2004    Reply    New Discussion   

I know of another simple way to make a window pop-up so you can suggest to your visitors to make your site their homepage.

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   

It depends on what type of prompt/alert you want.

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>


B)

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   

Can't you make a question window with Javascript? I'm not an expert on Javascript (I actually don't know anything about it), but I know it can be done in VB, problem is, can it be done in Javascript? Something like this:

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   

Grrr. You're the type of person we all don't like. j/k.

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   

I have a further question. How can I actually create multiple pop-ups that trigger by a mouse click over a particular area in a picture! I WILL ACCEPT ANY SUGGESTIONS OR SCRIPT THAT MAY HELP and give me an idea or two!!! THanks

-Badi

Wed Sep 26, 2007    Reply    New Discussion   

Quickly Post to How To Create A Popup Window With Javascript?  w/o signup Share Info about How To Create A Popup Window With Javascript?  using Facebook, Twitter etc. email your friend about How To Create A Popup Window With Javascript? Print
Reply / Comment Ask a Question? Share / Bookmark E-Mail a Friend Print


Javascript Javascript  Javascript Javascript (8) (5) Javascript sources Links to online javascript resources  Javascript sources Links to online javascript resources