Jump to content



Welcome to AstaHost - Dear Guest , Please Register here to get Your own website. - Ask a Question / Express Opinion / Reply w/o Sign-Up!
Photo
- - - - -

How To Create A Popup Window With Javascript?


21 replies to this topic

#1 soleimanian

soleimanian

    End Of Computer

  • Members
  • 346 posts
  • Location:.:: MARS ::.
  • Interests:smoking, drinking, gambling

Posted 05 September 2004 - 06:28 PM

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

#2 jcguy

jcguy

    Premium Member

  • Members
  • 382 posts

Posted 06 September 2004 - 07:46 AM

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.codelifte.../pop5index.html.

Either way simply follow the instructions and you can get your pop-up very quickly.

#3 wappi

wappi

    Newbie [ Level 1 ]

  • Members
  • 2 posts

Posted 06 September 2004 - 11:28 AM

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.

#4 overture

overture

    Premium Member

  • Members
  • 208 posts
  • Location:England
  • Interests:Web Design, Web Programming, Software Programming, Drawing, Digital Art :D

Posted 07 September 2004 - 01:36 PM

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:

<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.

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 :).

#5 dissipate

dissipate

    Advanced Member

  • [HOSTED]
  • 120 posts

Posted 12 September 2004 - 02:41 PM

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.

#6 overture

overture

    Premium Member

  • Members
  • 208 posts
  • Location:England
  • Interests:Web Design, Web Programming, Software Programming, Drawing, Digital Art :D

Posted 12 September 2004 - 03:12 PM

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'.

#7 currahee

currahee

    Member - Active Contributor

  • [HOSTED]
  • 82 posts
  • Location:At my computer desk

Posted 12 September 2004 - 04:47 PM

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.

#8 OrbitPoints

OrbitPoints

    Member [ Level 1 ]

  • [HOSTED]
  • 31 posts
  • Interests:Computer programming, engines, rockets, women. Order of importance depends on many different things :)

Posted 13 September 2004 - 02:12 AM

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.

#9 OrbitPoints

OrbitPoints

    Member [ Level 1 ]

  • [HOSTED]
  • 31 posts
  • Interests:Computer programming, engines, rockets, women. Order of importance depends on many different things :)

Posted 13 September 2004 - 02:32 AM

<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.

#10 OrbitPoints

OrbitPoints

    Member [ Level 1 ]

  • [HOSTED]
  • 31 posts
  • Interests:Computer programming, engines, rockets, women. Order of importance depends on many different things :)

Posted 13 September 2004 - 02:39 AM

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>

#11 scryoko

scryoko

    Member [ Level 1 ]

  • Members
  • 37 posts
  • Interests:One could say quite a number of things about me, but let's just brief it all up, shall we? ^_~ Okay, so I'm just you're average sophmore that goes to that horrid institution they call college ^_^ whose life (or lack thereof) revolves solely around a computer, one involving my extraordinarily unnatural obsession with anime, manga, and fanfics (shounen-ai / yaoi / het) -- AKA: without a computer, I'm as good as dead. ^_~

Posted 11 January 2006 - 04:20 PM

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.

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:

<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

#12 Nexmon

Nexmon

    Newbie [ Level 1 ]

  • Members
  • 5 posts
  • Location:Nebraska

Posted 12 February 2006 - 11:19 PM

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:
<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:
<body onunload="alert('Place your message here!');">

Also, there is one when a visitor moves their pointer over a link:
<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:
<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.
<body onload="alert('Place your message here!');"
onunload="alert('Place your second message here!');">


#13 warbird

warbird

    Little MechBirdie

  • Members
  • 299 posts
  • Location:Down here in Holland

Posted 14 February 2006 - 01:56 PM

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:

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=-

#14 twitch

twitch

    Veteran Nut

  • Members
  • 527 posts
  • Gender:Male
  • Location:UK
  • Interests:Many.

Posted 14 February 2006 - 05:51 PM

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.

#15 Guest_FeedBacker_*

Guest_FeedBacker_*
  • Guests

Posted 26 September 2007 - 09:01 PM

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

#16 Guest_FeedBacker_*

Guest_FeedBacker_*
  • Guests

Posted 14 February 2008 - 08:00 PM

You can try this code, Its correct
How To Create A Popup Window With Javascript?

<HEAD>




<!-- STEP TWO: Use the following button code for the new window -->

<form>
<input type=button value="Popup Window" onClick="javascript:popUp('This area please mention the your Folder or file')">
</form>

-Ganesh

#17 techyguru007

techyguru007

    Newbie [ Level 1 ]

  • Members
  • 2 posts

Posted 01 April 2008 - 09:59 PM

Hey I made a tut on youtube.

Here's the link:

There's no sound. But it tells you how to make a simple pop-up box.

#18 Guest_FeedBacker_*

Guest_FeedBacker_*
  • Guests

Posted 09 April 2008 - 08:42 AM

Call javascript from server side
How To Create A Popup Window With Javascript?

Hello friends,

I have one Query in javascript.. I call javascript function server side without any event fire like onblur,mouseover etc. And after the function then return server side..

Please help me this query


Regards,
Prashant

-reply by prashant

#19 java-area

java-area

    Member [ Level 1 ]

  • [HOSTED]
  • 47 posts

Posted 15 April 2008 - 09:19 PM

I think the common way to create a popup with JavaScript is using Div elements.
You can simply put any Html code into the tag DIV and make this Div unvisible.
For example:

<body>
......

<DIV id="myTestDiv" style="left:-1000px;top:-1000px;disply:none;position:absolute;'>
<table border=1>
<tr>
<td>Menu Item 1</td>
</tr>
<tr>
<td>Menu Item 2</td>
</tr>
</table>
</DIV>
.....
</body>


When my popup window (created as Div element) is unvisible, I do not worry about its location on the screen - it does not matter. That's way I put negative values for top and left coordinates.
However, before visualing I should move it to appropriated location. It can be done by JavaScript using attribute style. For example, I can move my popup to any absolute location on current page:
&lt;script language='javascript'>
function moveMyPopup() {
var mypopup = document.getElementById('myTestDiv');
mypopup.style.top = '25px';
mypopup.style.left = '100px';
}
</script>

After moving I can do it visible:
pop.style.display = '';
Or hide it again:
pop.style.display = 'none';

#20 java-area

java-area

    Member [ Level 1 ]

  • [HOSTED]
  • 47 posts

Posted 16 April 2008 - 02:35 PM

Comment to my previous message:
Div elements are used very often for creating poipup menu on the first (main) page of Web sites.
But we have to keep in mind, that different browser have different Javascript systacsis for moving and hiding/showing elements on the screen.
Look at documentation attentively!

Edited by java-area, 16 April 2008 - 02:36 PM.




Reply to this topic



  


0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users