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 IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Java applet to use for a pop up window 1

Status
Not open for further replies.

user2

Technical User
Aug 10, 2001
70
US
I see a lot of JAVA code to make a pop up window . How should I use it?(To start my website at the very start? ) Is this enough? : <script> newwin=window.open('pop.htm','PopupTest','width=100,height=100')</script>

is it a good idea to do it or should I put it under the button to click for the user? Thanks in advance
 
You can use whatever method you like to pop up a window. You can put your code in a function:

function popUp() {
var newwin = window.open('pop.htm','PopupTest','width=100,height=100');
}

and then use an anchor to call it:

<a href=&quot;javascript:popUp()&quot;>click me</a>

&quot;click me&quot; could also be an image, of course.

Or you could put it in a form:

<form onSubmit=&quot;popUp()&quot;>
<input type=submit>
</form>

Or you can have the window pop up when the page is done loading:

<body onLoad=&quot;popUp()&quot;>

You have a lot of options!
 
Oh and it's not Java, it's Javascript... not an applet at all but a script. TOTALLY different.
 
To: GLOWBALL
Cc:
Bcc:
Subject:CAN YOU Please HELP ME (Thank you for your earliar suggestion)
--------


This is part of my site : I put in the script to have a pop up

window ,I want to know what the error means :Menu undefined

html

head





title The

Center /title

meta http-equiv=&quot;Content-Type&quot; content=&quot;text/html;&quot;

meta name=&quot;keywords&quot; content=&quot;gart&quot;

meta

name=&quot;description&quot; content=&quot;some keyword.&quot;



script

language=&quot;Javascript&quot;
newwin=window.open('pop.htm','PopupTest','width=100,height=100')
/script







script

language=&quot;JavaScript&quot;



function MM_findObj(n, d) {

var p,i,x; if(!d) d=document;

if((p=n.indexOf(&quot;?&quot;)) 0 parent.frames.length) {

d=parent.frames[n.substring(p+1)].document;

n=n.substring(0,p);}

if(!(x=d[n]) d.all) x=d.all[n]; for (i=0;!x i d.forms.length;i++)
x=d.forms[n];

for(i=0;!x d.layers i d.layers.length;i++)
x=MM_findObj(n,d.layers.document); return x;

}

function

MM_swapImage() {

var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array;

for(i=0;i (a.length-2);i+=3)

if ((x=MM_findObj(a))!=null){document.MM_sr[j++]=x; if(!x.oSrc)
x.oSrc=x.src; x.src=a[i+2];}

}

function MM_swapImgRestore() {



var i,x,a=document.MM_sr; for(i=0;a i a.length (x=a) x.oSrc;i++)
x.src=x.oSrc;

.....



This is my pop up window Where could be the

problem



head

title popup /title





meta

name=&quot;description&quot; content=&quot;&quot;

meta name=&quot;keywords&quot; content=&quot;&quot;

/head

body text=maroon

table border=2 bgcolor=gold height=400 width=600 cellspacing=2
cellborder=2

tr td align=center img src=&quot;C:\my documents\my pictures\earth4.gif&quot;
/td /tr

tr td align=center COME JOIN US

FOR:

bR NEW LECTURE SERIES STARTING THIS

WEEK /br

/td /tr /table

/body

/html



 
Try this test page (this is the whole page, put it in the same directory as pop.htm, which should already exist):
Code:
<html>
<head>
    <title>Testing</title>
<script language=&quot;JavaScript&quot; type=&quot;text/javascript&quot;>
function popUp() {
    var newwin = window.open('pop.htm','PopupTest','width=100,height=100');
    newwin.focus();
    }
</script>
</head>
<body>

<a href=&quot;javascript:popUp()&quot;>click me</a>

</body>
</html>
 
Thank you, I appreciate your prompt response. I did the testing , Now it says runtime error, null is not an object
What should I do? It is in the working directory of Coffeecup. My website file is (part of file )also in the same directory
 
Hmm, this is pretty standard stuff -- have you had problems with other popup windows, do you find you get a lot of Javascript errors on other pages?

Anyone else out there have any ideas?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top