Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

JavaScript Forum


You are currently viewing our JavaScript Forum as a guest. Please register to participate.
Login



Reply
IE bug -- using javascript: to open new window -- how to fix?
Old 07-09-2006, 10:55 PM IE bug -- using javascript: to open new window -- how to fix?
serandfae's Avatar
Do the "Evil Nanner" !!!

Posts: 8,936
Name: Tim Daily
Location: Apex, NC, US, Sol 3
Trades: 0
I've got image links on my site, and Internet Explorer won't open them. If I try to right-click open in new window, IE says it can't open the page. My pages are W3C valid, and all other browsers have no problem with the following coding. Help with a workaround?

This is what's in my head section:
<script language="JavaScript" type="text/javascript">
<!-- Hide script from old browsers

function newWindow(imgjpg) {
imgName = "../images/cabinets/" + imgjpg
winName = imgjpg + "Win"
imgWindow = window.open(imgName,winName)
imgWindow.focus()
}

// End hiding script from old browsers -->
</script>

Each of my image links has a variation of this (and they're each enclosed in a td tag if that makes a difference)

<a href="javascript:newWindow('concept1.jpg')">

Thanks to anyone who can help.
serandfae is offline
Reply With Quote
View Public Profile Visit serandfae's homepage!
 
 
Register now for full access!
Old 07-10-2006, 01:13 AM Re: IE bug -- using javascript: to open new window -- how to fix?
vangogh's Avatar
Post Impressionist

Posts: 10,688
Name: Steven Bradley
Location: Boulder, Colorado
Trades: 0
I think in IE you need to use the var keyword when declaring any new variable. Try:

function newWindow(imgjpg) {
var imgName = "../images/cabinets/" + imgjpg
var winName = imgjpg + "Win"
var imgWindow = window.open(imgName,winName)
imgWindow.focus()
}

I think that will fix the IE issue.
__________________
l Search Engine Friendly Web Design |
Please login or register to view this content. Registration is FREE

l Tips On Marketing, SEO, Design, and Development |
Please login or register to view this content. Registration is FREE

l
Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
vangogh is offline
Reply With Quote
View Public Profile Visit vangogh's homepage!
 
Old 07-10-2006, 01:44 PM Re: IE bug -- using javascript: to open new window -- how to fix?
serandfae's Avatar
Do the "Evil Nanner" !!!

Posts: 8,936
Name: Tim Daily
Location: Apex, NC, US, Sol 3
Trades: 0
Tried doing that, didn't work. Wouldn't even open anything, much less put out a page not found window.

Thanks just the same, though.
serandfae is offline
Reply With Quote
View Public Profile Visit serandfae's homepage!
 
Old 07-10-2006, 01:50 PM Re: IE bug -- using javascript: to open new window -- how to fix?
funkdaddu's Avatar
Web Design Snob

Posts: 635
Trades: 0
Why not link directly to the jpeg for non-JS browsers, and then do:
Code:
function newWindow(imgjpg) {
winName = imgjpg + "Win"
imgWindow = window.open(imgjpg,winName)
imgWindow.focus()
}
then do onclick="newWindow(this.href); return false;"

That way your images are still accessible to non-js enable browsers and the regular link will work as well.
funkdaddu is offline
Reply With Quote
View Public Profile Visit funkdaddu's homepage!
 
Old 07-10-2006, 01:58 PM Re: IE bug -- using javascript: to open new window -- how to fix?
Extreme Talker

Posts: 160
Trades: 0
Avoid using a dot in the window target name.
In your code, "winName" will contain a dot and fail - "concept1.jpgWin".
Omit the dot and your code will not throw an error.
ElectricSheep is offline
Reply With Quote
View Public Profile
 
Old 07-10-2006, 02:27 PM Re: IE bug -- using javascript: to open new window -- how to fix?
serandfae's Avatar
Do the "Evil Nanner" !!!

Posts: 8,936
Name: Tim Daily
Location: Apex, NC, US, Sol 3
Trades: 0
funkdaddu, that worked beautifully. Thanks!
serandfae is offline
Reply With Quote
View Public Profile Visit serandfae's homepage!
 
Old 07-10-2006, 03:58 PM Re: IE bug -- using javascript: to open new window -- how to fix?
funkdaddu's Avatar
Web Design Snob

Posts: 635
Trades: 0
Quote:
Originally Posted by ElectricSheep
Avoid using a dot in the window target name.
In your code, "winName" will contain a dot and fail - "concept1.jpgWin".
Omit the dot and your code will not throw an error.
Yup, I missed that... if you don't need to access the windows after they've been opened, you can just leave the name out. It should make a new one for each window:
Code:
function newWindow(imgjpg) {
imgWindow = window.open(imgjpg)
}
funkdaddu is offline
Reply With Quote
View Public Profile Visit funkdaddu's homepage!
 
Old 07-10-2006, 05:31 PM Re: IE bug -- using javascript: to open new window -- how to fix?
serandfae's Avatar
Do the "Evil Nanner" !!!

Posts: 8,936
Name: Tim Daily
Location: Apex, NC, US, Sol 3
Trades: 0
A related question is this:

Is it now just completely inadvisable to use the javascript: attribute within a XHTML tag?
serandfae is offline
Reply With Quote
View Public Profile Visit serandfae's homepage!
 
Reply     « Reply to IE bug -- using javascript: to open new window -- how to fix?
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.33767 seconds with 12 queries