Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to make a pop up box 1

Status
Not open for further replies.

likelylad

IS-IT--Management
Jul 4, 2002
388
GB
Hi

My knowledge of HTML is very basic.

What I would like to happen is that on opening an index.html file a popup box would appear giving a message.

I would be grateful if someone would guide me through it in all its details.

[Pipe]
 
Put this into the <head> of your html:
[tt]
</script>
function popupPage(url,w,h) {

var windowprops = &quot;location=no,scrollbars=no,menubar=no,toolbar=no,resizable=no&quot; + &quot;,left=100,top=100&quot; + &quot;,width=&quot; + w + &quot;,height=&quot; + h + &quot;;&quot;;
// change the top and left values to adjust window position

a = window.open(url,&quot;popup&quot;,windowprops);
a.document.open();
a.document.write(&quot;<html><body><h3>Message Header</h3><p>Message text goes here.</p></body>&quot;);//here is the message that will be displayed
a.document.close();
}
</script>
[/tt]

If you want to open a popup when you click the link, do this:
[tt]
<a href=&quot;#&quot; onclick=&quot;popupPage('',200,300); return false;&quot;>open new win</a>
[/tt]
If you want it to appear when you click a button, do this:
[tt]
<input type=&quot;button&quot; value=&quot;open new win&quot; onclick=&quot;popupPage('',200,300)&quot;>
[/tt]
If you want it to load autamatically when page finish loading, do this:
[tt]
<body onload=&quot;popupPage('',200,300)&quot;>
[/tt]

You can adjust the window winth/height by changing the values in function call:
popupPage('',W,H)

And, finally, it's a good idea to search HTML and JS forums/FAQs first, because there questions are discussed very ofter.
 
Do you want a popup box or window? If you only want a popup box, do this:

<body onLoad=&quot;alert('This is a message in a popup box!!!');&quot;>

Rick
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top