View Full Version : Open Link in new Window

04-03-2003, 05:09 AM

I find the right-click menu (http://www.javascriptkit.com/script/script2/rightclickmenu.shtml), very helpful. I am not able to have the links open in a new windwo and am looking for some assistance to solve this. I would appreciate if someone could point me in the right direction.

Thank you very much for your time.

04-03-2003, 05:28 AM
in the .js file there is a line does opening pages on click:

preitem+=("<a href='#' onmousedown='parent.window.location.href=\""+lnk+"\"'><img src='"+ico+"' width='16' height='16' class='ico'> "+txt+"</a>")

04-03-2003, 05:47 PM
Hi V,

I pretty much gave up to figure this one out before i posted...
...would you be able to provide me the resolution to solve my problem?

As mentioned, i would like to open the links in a new window.

Thank you.

04-03-2003, 06:08 PM
ok, try change this:

preitem+=("<a href='#' onmousedown='target="_blank";target.window.location.href=\""+lnk+"\"'><img src='"+ico+"' width='16' height='16' class='ico'> "+txt+"</a>")

change _blank to whateve name u want for the new window.

04-03-2003, 10:40 PM
Hi V,

I tried your suggestion without luck. I copy-pasted your code-line and did not change a thing. Actually, the right-click menu did not appear at all. If i deleted the " " around _blank, it came back with a script error msg.
Error: '_blank' is undefined, Code: 0

Any idea how i can get this 'going'?
Thank you again.

04-03-2003, 10:46 PM
sorry, I'm 100% newbie at JS, but try to move
outside of that line (put it before that line)

04-04-2003, 03:32 PM

preitem+=("<a href='#' onmousedown='window.open(\""+lnk+"\");return false'><img src='"+ico+"'....


preitem+=("<a href=\""+lnk+"\" target=\"_blank\"><img src='"+ico+"'....

04-04-2003, 06:55 PM
Hello PauletteB,

Thank you for your reply. I appreciate all help i can get. Unfortunately, both of your suggestions do notwork.

preitem+=("<a href='#' onmousedown='window.open(\""+lnk+"\");return false'><img src='"+ico+"'....
Does create an error 'Not implemented', code "0"

preitem+=("<a href=\""+lnk+"\" target=\"_blank\"><img src='"+ico+"'....
Does not seem to work at all.

Would you have any other idea how i can get the link to open in a new window?

Thank you so much for your time.

04-04-2003, 06:58 PM

Thank you for haning in there with me. I am list with this thing and unfortunately, your other suggestion did not work. any otehr idea?

04-04-2003, 11:16 PM
Think you can post the link to your test page?
Also, do you have Norton, or other security / pop-up remover?

04-05-2003, 06:12 AM
Hi PauletteB,

The site i am working on is actually not out on the www. I have put a rather large reference database together and used a simple software for the 'web based' part of this database. I dont want to bore you with too many details, but some info may be helpful. The software i am using is Adobe PageMill, a rather old piece of work, but it is just enough to fit our needs when it goes to have our products, description, pictures, catalogs and so on at our fingertips. There are approx. 2500 files linked and cross referenced with approx. 130 'web sites'. One page has links out to the internet, which we use many times per hour. These links do open in a new window without a problem, but one does have to get to the 'web links' page. I would like to use this 'right-click' menu on the entry page to the database for the links we use most often. The links in the test file are the ones that came with the cut-n-paste script and do open just fine, but not in a new window. I am going to attach the test.html and the rightmenu.js as test.zip file.

Oh, we use IE 6.x on WIN 2000, if that should matter at all.

To answer your question. There is no pop-up remover or Norton. Any other web sites and links seem to be working. Links do open, and pop-ups do come through w/o problems.

Thank you again so much for your time looking into this.

04-05-2003, 08:45 AM
I'm also a noob but won't it work if you target itlogically like this:
target=\"new\" ?

That's all I can think up...

04-05-2003, 03:24 PM

The script was written for IE to be opened in the parent. It cannot be simply edited to be opened in a new window.

I, and likely the others posters, had based our replies on the one-liner: preitem+=("<a href....



04-05-2003, 06:58 PM
Hello Paulette,
I sure appreciate the time you took to look into this for me. Unfortunately I know nothing about js programming and was kind of surprised what neat things one can do with it and was hoping I could use this little gimmick. Well, we can do without it I guess. I just thought it would be much easier to change the window location, just like it is in html.
Once again, thank you.