Welcome Guest ( Log In | Register )



2 Pages V  < 1 2  
Reply to this topicStart new topic
> How To Create A Popup Window With Javascript?
scryoko
post Jan 11 2006, 04:20 PM
Post #11


Member [ Level 1 ]
Group Icon

Group: Members
Posts: 37
Joined: 23-June 05
Member No.: 6,514



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
Go to the top of the page
 
+Quote Post
Nexmon
post Feb 12 2006, 11:19 PM
Post #12


Newbie [ Level 1 ]
Group Icon

Group: Members
Posts: 5
Joined: 12-February 06
From: Nebraska
Member No.: 11,249



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>


ohmy.gif

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!');">
Go to the top of the page
 
+Quote Post
warbird
post Feb 14 2006, 01:56 PM
Post #13


Little MechBirdie
Group Icon

Group: Members
Posts: 299
Joined: 23-March 05
From: Down here in Holland
Member No.: 3,178



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=-
Go to the top of the page
 
+Quote Post
twitch
post Feb 14 2006, 05:51 PM
Post #14


Veteran Nut
Group Icon

Group: Members
Posts: 527
Joined: 4-October 05
From: UK
Member No.: 8,895



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.

Go to the top of the page
 
+Quote Post
iGuest
post Sep 26 2007, 09:01 PM
Post #15


Newbie [ Level 1 ]
Group Icon

Group: Members
Posts: 0
Joined: 1-November 07
Member No.: 25,869



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
Go to the top of the page
 
+Quote Post
iGuest
post Feb 14 2008, 08:00 PM
Post #16


Newbie [ Level 1 ]
Group Icon

Group: Members
Posts: 0
Joined: 1-November 07
Member No.: 25,869



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
Go to the top of the page
 
+Quote Post
techyguru007
post Apr 1 2008, 09:59 PM
Post #17


Newbie [ Level 1 ]
Group Icon

Group: Members
Posts: 2
Joined: 1-April 08
Member No.: 29,551



Hey I made a tut on youtube.

Here's the link: http://youtube.com/watch?v=1KTe6mWhBq0

There's no sound. But it tells you how to make a simple pop-up box.
Go to the top of the page
 
+Quote Post
iGuest
post Apr 9 2008, 08:42 AM
Post #18


Newbie [ Level 1 ]
Group Icon

Group: Members
Posts: 0
Joined: 1-November 07
Member No.: 25,869



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
Go to the top of the page
 
+Quote Post
java-area
post Apr 15 2008, 09:19 PM
Post #19


Member [ Level 1 ]
Group Icon

Group: [HOSTED]
Posts: 47
Joined: 4-February 08
Member No.: 28,119



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:

HTML
<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:
HTML
&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';
Go to the top of the page
 
+Quote Post
java-area
post Apr 16 2008, 02:35 PM
Post #20


Member [ Level 1 ]
Group Icon

Group: [HOSTED]
Posts: 47
Joined: 4-February 08
Member No.: 28,119



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!

This post has been edited by java-area: Apr 16 2008, 02:36 PM
Go to the top of the page
 
+Quote Post

2 Pages V  < 1 2
Reply to this topicStart new topic

Collapse

> Similar Topics

Topics Topics
  1. Getting Screen Resolution using Javascript.(8)
  2. javascript vs java(12)
  3. Javascript: Disable Mouse Right-click In Browser(16)
  4. Best Way To Learn Javascript(9)
  5. Javascript: Text To Texbox And Back To Text(2)
  6. Unobtrusive Javascript Image Rollovers(0)
  7. Dynamicdrive: Good Site For JavaScript Codes(5)
  8. Downloads With Javascript?(7)
  9. Javascript: Simple Slidedown Menu(2)
  10. JavaScript: Simple Dropdown Menu(1)
  11. Calling Of Functions Between Mulitple External Javascript Files(2)
  12. Javascript: Browser Detection Script(0)
  13. JavaScript: Hide And Show Any Element With CSS(5)
  14. Ever Needs To Find Out A Table Height Or With With JavaScript(2)
  15. Create And Import JavaScript Modules For A Large Script(2)
  1. Vertical Marquee Using JavaScript(0)
  2. JavaScript Frames & Querystring(4)
  3. JavaScript Off Redirect Script(2)
  4. I Need Help With Javascript.(7)
  5. Problems With Dynamically Loading Javascript(2)
  6. Add Text To Textarea(6)
  7. Javascript Question(4)
  8. Javascript: How Do I Create Embedded Pop-up Windows?(7)
  9. Problem With Javascript Alert();(9)
  10. Include Function For Javascript(7)
  11. Fun With Javascript And Forms(2)
  12. Javascript Help Needed : Alert(z) Works Fine But Document.write Not(2)
  13. Javascript Changes Aren't Working.(6)


 



- Lo-Fi Version Time is now: 22nd August 2008 - 01:37 AM