Log in

View Full Version : javascript:window.open



Pinky
12-19-2006, 10:48 AM
Please help. :mad: I am having trouble with this coding.

eg. IMAGE (on line 120)
<a href="#" SPAN class=popup
onclick='javascript:window.open("file:///url.htm","blank","toolbar=no,location=no,width=600,height=350,top=0,left=0,scrollbars=yes")'; return false;"><span style="text-decoration: none; font-weight:700"><img border="0" src="image.jpg" width="35" height="35" alt="images"></span></a>

I want to determine the precise location of the pop-up (on line 120 and not at the top of the page).

djr33
12-19-2006, 11:04 AM
onclick='javascript:window.open("file:///url.htm","blank","toolbar=no,location=no,width=600,height=350,top=0,left=0,scrollbars=yes")'; return false;">....quite a few problems--

Quotes must match... you open with a single quote, and close with double. Also, for html attributes, use double quotes. Inside javascript, use single. And javascript: is an alternate way to use javascript that I've only seen used with a elements within the href part.... href="javascript:....", not like this. onClick is javascript to begin with, so no need to set that.

Here's the fixed version:
onclick="window.open('file:///url.htm','blank','toolbar=no','location=no','width=600',height=350,top=0,left=0,scrollbars=yes'); return false;">And... I give up now. You have no quotes around the attributes in the function near the end, and not sure if you define it like that (I'm no JS expert). I'm not used to seeing something=value, within a function like that. Not sure how to fix it. I'd suspect that it's just the value... like 600, not width=600, but not exactly sure. Where did you get the code? I'm sure it tells you somewhere...

Pinky
12-19-2006, 11:08 AM
Please don't give up on me :( I am new to all these codes. I will try your fixed code and report back. Thank you for your help.

BLiZZaRD
12-19-2006, 11:17 AM
its the exact same as making a pop up in Flash (as that uses JS as well....

take what you can from this snippet:



<SCRIPT LANGUAGE="JavaScript">
function popup() {
window.open('pagetopopup.html','','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,width=100,height=100,left=200,top=200') ;
}
</script>

djr33
12-19-2006, 12:23 PM
Ok, I'm off on the inner quotes. That looks like it should work. I'm just not used to that format. I really need to figure out Javascript sometime soon... I just do PHP. Heh.

BLiZZaRD
12-19-2006, 12:39 PM
The joys of AS and JS being so similar :D I don't know much JS either. I am doing the w3c lessons on it right now, though, piecing it together as best I can. It's not as hard as I thought it would be though, so that helps.

mwinter
12-19-2006, 01:47 PM
The joys of AS and JS being so similar

They are both ECMAScript implementations.



I don't know much JS either. I am doing the w3c lessons on it right now ...

As far as I'm aware, the W3C have no lessons on ECMAScript or its derivatives. Are you getting confused with W3Schools? These are entirely unrelated sites.

I'm far from impressed by W3School's tutorial. They confuse the language and objects provided by the host, they perpetuate script "hiding" nonsense, their understanding of variable lifetime is rudimentary, they seem to recommend using for..in statements with arrays, the summary of exception handling is abominable, they think that \& is an escape sequence and recommend line continuation in string literals using a backslash - something that's forbidden (though tolerated in some browsers). That's in the "basic" section, and far from exhaustive.

The "test" is quite entertaining, especially with a few wrong and misleading questions, and how little it has to do with the language.

Mike

BLiZZaRD
12-19-2006, 04:45 PM
Yes sorry had validation things on my mind.

Is there a better online tut than W3schools?

mwinter
12-19-2006, 06:07 PM
Is there a better online tut than W3schools?

I don't know, but I doubt there are any good tutorials. They've never been mentioned on c.l.javascript. Tutorials are usually OK as far as syntax is concerned, but they usually fall flat on their face when it comes to usage and best practice.

You're always welcome to ask any question about the language in the JavaScript forum, here (or in c.l.j, if you have newsgroup access). I know I'll be happy the help. :)

Mike

aliasghar.ali
12-22-2006, 08:52 AM
Hi. Have u tried www.javascript.com....

This site is also very good. Its better than w3school of thought :)

mwinter
12-22-2006, 11:33 AM
Have u tried www.javascript.com....

Yes, it's horrible. Worse than W3Schools.

Mike

akvriksha15
08-29-2009, 08:54 PM
onclick='javascript:window.open("file:///url.htm","blank","toolbar=no,location=no,width=600,height=350,top=0,left=0,scrollbars=yes")'; return false;">....quite a few problems--

Quotes must match... you open with a single quote, and close with double. Also, for html attributes, use double quotes. Inside javascript, use single. And javascript: is an alternate way to use javascript that I've only seen used with a elements within the href part.... href="javascript:....", not like this. onClick is javascript to begin with, so no need to set that.

Here's the fixed version:
onclick="window.open('file:///url.htm','blank','toolbar=no','location=no','width=600',height=350,top=0,left=0,scrollbars=yes'); return false;">And... I give up now. You have no quotes around the attributes in the function near the end, and not sure if you define it like that (I'm no JS expert). I'm not used to seeing something=value, within a function like that. Not sure how to fix it. I'd suspect that it's just the value... like 600, not width=600, but not exactly sure. Where did you get the code? I'm sure it tells you somewhere...
I used the window.open method and it works but i want to change the status bar text of the opening window. i tried a lot but none of them is working kindly help me how can i do the both things together opening a new window with changing the status bar text of it.