Click to See Complete Forum and Search --> : Window Popup


ker11
08-23-2003, 06:24 PM
Hello...

I found a window popup maker at javascript.internet.com created by Nic Wolfe. I used it and it created a popup for me which I placed according to his directions in my document. When I run it I get an error. Can someone help me with it?

I'm trying to learn javascript as fast as I can but it is a slow pace for me.

The following is what I placed between the <head></head> tags in my document:

<SCRIPT LANGUAGE="JavaScript">
<!-- Idea by: Nic Wolfe (Nic@TimelapseProductions.com) -->
<!-- Web URL: http://fineline.xs.mw -->
<!-- This script and many more are available free online at -->
<!-- The JavaScript Source!! http://javascript.internet.com -->
<!-- Begin
function popUp(URL)
{
day = new Date();
id = day.getTime();
eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,width=250,height=250,left = 387,top = 259');");
}
// End -->
</script>

The following is in the body section of my document:

<A HREF="javascript:popUp('http://www.bible.org/cgi-bin/netbible.p1?book=luk&chapter=1&verse=80')">Luke 1:80</A>

The text shows as being a link and I click on it. Window does popup but that is when I get an error.

Line: 1
Char: 1
Error: Object expected
Code: 0
URL: javascript:popUp('http://www.bible.org/cgi-bin/netbible.p1?book=luk&chapter=1&verse=80')

That is the error I get....

If you can see what it is I'm doing wrong and let me know I would be very grateful. I am new at javascript and desire very much to continue learning about it.

I tried several different url's to make sure I was not putting in an erroreous one but I get the same result each time.

Sincerely,
ker11

Charles
08-24-2003, 06:26 AM
You've got another problem there that you don't realize. Even if we correct your error you will simply end up with a link that doesn't work at all for the 13% of users who do not use JavaScript. And some of those good people cannot use JavaScript because of some disability. Use instead:

<a href="http://www.bible.org/cgi-bin/ netbible.p1?book=luk&chapter=1&verse=80" onclick="window.open(this.href, 'child', 'width=250,height=250,left=387,top=259'); return false">Luke I:80</a>

pelegk1
08-24-2003, 08:15 AM
url u toke the script?

ker11
08-24-2003, 01:38 PM
Thank you Charles for your help and your advice. I corrected the link according to your directions. The link does work now. However, I wanted the page to open in a popup window the size indicated and centered in the page. Instead the link opens in a full window. Do I handle this in the script that is located in the <head></head> section? I made sure it was all on one line. I have it set to height of 250 and width of 250 but it is not doing this. I am sure there is a correlation between the <a href...> link and the script itself but I don't quite understand it. So if you would be so kind as to point me in the correct direction one more time I would be very grateful.

Sincerely,
Ker11

Charles
08-24-2003, 02:03 PM
It looks like you're doing something wrong. Please post the URL.

David Harrison
08-24-2003, 02:11 PM
If the prupose of the link is to open a new window, you may want to think about adding:

target="_blank"

to your a tag. This will open a new window even for those without javascript. However it is considered bad practice to open new windows.

Khalid Ali
08-24-2003, 02:20 PM
Originally posted by lavalamp

target="_blank"

target attribute for anchor tags is only allowed in Transitional and frameset DTD's,I'd ratehr not use it at all..(potential future compatibility problems)

David Harrison
08-24-2003, 02:24 PM
Well I did say:However it is considered bad practice to open new windows.

ker11
08-24-2003, 03:28 PM
Thanks everyone for the responses and help. I tried the target="_blank" in the a tag but it still doesn't do what I want it to do. The link works and a new window opens but it is full screen and not the size I want. I want a popup screen the size that I tell it (which in this case was 250 X 250 although that was just to experiment). I guess I will not worry with it anymore or bother you all anymore with it.

Thanks again for your responses.

Sincerely,
Kerr11

David Harrison
08-24-2003, 03:31 PM
No, the target="_blank" was for the people with no js, so at least it still opens a ne window even if it isn't the right size.

Charles
08-24-2003, 03:53 PM
Originally posted by ker11
Thanks everyone for the responses and help. I tried the target="_blank" in the a tag but it still doesn't do what I want it to do. The link works and a new window opens but it is full screen and not the size I want. I want a popup screen the size that I tell it (which in this case was 250 X 250 although that was just to experiment). I guess I will not worry with it anymore or bother you all anymore with it.

Thanks again for your responses.

Sincerely,
Kerr11 What you want is easily achieved and if you would post our URL we could spot the problem rather quickly.

ker11
08-24-2003, 04:26 PM
I do not have a url. The file I am using is a file I have on my computer written in HTML. The program I use has a HTML viewer which I use. The reason I wanted to be able to do this is I wanted to share this file with others on the community I belong to. I would want them to be able to click on a particular link (in this case a bible verse) and it carry them to it at the site I listed. So I personally do not have a web page as I personally have no need for one nor do I forsee the need for one personally.

Sincerely,
Ker11

David Harrison
08-24-2003, 04:48 PM
To pelegk1:

I'm not entirely sure what you meant but I think you were asking where he got the script from. He got it from http://www.javascriptsource.com/.