JavaScript Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me

The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.

Go Back   Dev Shed ForumsWeb DesignJavaScript Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old August 10th, 2008, 01:18 AM
Matt1776's Avatar
Matt1776 Matt1776 is offline
Recovering Intellectual
Dev Shed Beginner (1000 - 1499 posts)
 
Join Date: Jun 2006
Location: Orange County, CA
Posts: 1,303 Matt1776 User rank is Major General (70000 - 90000 Reputation Level)Matt1776 User rank is Major General (70000 - 90000 Reputation Level)Matt1776 User rank is Major General (70000 - 90000 Reputation Level)Matt1776 User rank is Major General (70000 - 90000 Reputation Level)Matt1776 User rank is Major General (70000 - 90000 Reputation Level)Matt1776 User rank is Major General (70000 - 90000 Reputation Level)Matt1776 User rank is Major General (70000 - 90000 Reputation Level)Matt1776 User rank is Major General (70000 - 90000 Reputation Level)Matt1776 User rank is Major General (70000 - 90000 Reputation Level)Matt1776 User rank is Major General (70000 - 90000 Reputation Level)Matt1776 User rank is Major General (70000 - 90000 Reputation Level)Matt1776 User rank is Major General (70000 - 90000 Reputation Level)Matt1776 User rank is Major General (70000 - 90000 Reputation Level)Matt1776 User rank is Major General (70000 - 90000 Reputation Level) 
Time spent in forums: 1 Month 1 Week 1 Day 7 h 48 m 58 sec
Reputation Power: 784
Send a message via ICQ to Matt1776 Send a message via Skype to Matt1776
Window.open does not work in IE?

This is frustrating beyond all measure.

I have an external JS file defined as such:

Code:
<!--

function window_test_IE()
{

window.open('http://www.ioforge.com/', 'TEST', 'width=650, height=650');

}

//-->


And I call said function as such:

Code:
<a href="javascript:window_test_IE()">
<img src="URL/IMAGE" alt="ALT" class="thumb" />
</a>


But yet, even though FF works (of course) IE does not. It says 'Object Expected'. WTF Does that even MEAN? There are no arguments. How can it be expecting anything?
__________________
Bugs that go away by themselves come back by themselves
Beware - your loyalty will not be rewarded

Reply With Quote
  #2  
Old August 10th, 2008, 02:47 AM
jsKid's Avatar
jsKid jsKid is offline
Application is what Divides Us
Dev Shed Regular (2000 - 2499 posts)
 
Join Date: Dec 2002
Location: Titusville, FL
Posts: 2,179 jsKid User rank is Sergeant Major (2000 - 5000 Reputation Level)jsKid User rank is Sergeant Major (2000 - 5000 Reputation Level)jsKid User rank is Sergeant Major (2000 - 5000 Reputation Level)jsKid User rank is Sergeant Major (2000 - 5000 Reputation Level)jsKid User rank is Sergeant Major (2000 - 5000 Reputation Level)jsKid User rank is Sergeant Major (2000 - 5000 Reputation Level) 
Time spent in forums: 2 Weeks 2 Days 15 h 44 m 6 sec
Reputation Power: 57
Send a message via AIM to jsKid Send a message via MSN to jsKid
MySpace
It would be beneficial to use onclick over the javascript prefix to
the href of the anchor. May not necessarily fix your object expected error...

Edit:
Just a thought, the space after the comma in the properties
list being passed through the function may possibly be the
error that's being raised.

Edit:
Posted without readily checking for errors, see derelicts post
below... haha thanks d!

Code:
function pop(url,wtitle,wprop){
	if (!window.open){ return; }
	if (!win){ var win= window.open(url,wtitle,wprop); }
	if (win && win.focus){ win.focus(); }
}

Code:
<a href='url' title=''><img src='url/img.extension' alt='ALT' class='thumb' onclick="return !pop(this.href,'','');" /></a>
__________________
Download [ Fx | Op ] Validate [ Markup | Css ]

Last edited by jsKid : August 13th, 2008 at 01:04 AM.

Reply With Quote
  #3  
Old August 11th, 2008, 02:31 PM
derelict's Avatar
derelict derelict is offline
garish grotesque gargoyle
Dev Shed Beginner (1000 - 1499 posts)
 
Join Date: Mar 2006
Location: gracing gargantuan gothic gateways
Posts: 1,337 derelict User rank is General 1st Grade (Above 100000 Reputation Level)derelict User rank is General 1st Grade (Above 100000 Reputation Level)derelict User rank is General 1st Grade (Above 100000 Reputation Level)derelict User rank is General 1st Grade (Above 100000 Reputation Level)derelict User rank is General 1st Grade (Above 100000 Reputation Level)derelict User rank is General 1st Grade (Above 100000 Reputation Level)derelict User rank is General 1st Grade (Above 100000 Reputation Level)derelict User rank is General 1st Grade (Above 100000 Reputation Level)derelict User rank is General 1st Grade (Above 100000 Reputation Level)derelict User rank is General 1st Grade (Above 100000 Reputation Level)derelict User rank is General 1st Grade (Above 100000 Reputation Level)derelict User rank is General 1st Grade (Above 100000 Reputation Level)derelict User rank is General 1st Grade (Above 100000 Reputation Level)derelict User rank is General 1st Grade (Above 100000 Reputation Level)derelict User rank is General 1st Grade (Above 100000 Reputation Level)derelict User rank is General 1st Grade (Above 100000 Reputation Level) 
Time spent in forums: 2 Weeks 6 Days 8 h 35 m 8 sec
Reputation Power: 1036
this could also be because your function returns nothing. if you use the onclick and return false, then you should be in good shape. if you use the javascript: prefix, try wrapping the function call in a void() call:

javascript:void(window_test_IE());

void() tells IE that nothing is coming, so don't expect anything.

otherwise IE wants to take some action as a part of the link click. if your function returned a URL, I believe that URL would be loaded. if you return 'false' some versions of IE load a blank page saying 'false' (same for 'true').

the better solution, as mentioned by jsKid, is to run it as an onclick, and make sure your function returns false. then what the URL says doesn't matter... a good formation for compatability would be to follow jsKid's example (except, sorry jsKid, you needed to put your onclick on the link, not the image... I don't think images have .href properties )... I added some slight modifications...


Javascript Code:
Original - Javascript Code
  1. function pop(url,wtitle,wprop){
  2.     if (!window.open){ return; } // get out now if we can't do this basic function
  3.     // I killed the if(win), since win was a local var this was a meaningless check
  4.     var win= window.open(url,wtitle,wprop);
  5.     // next line important in case you open multiple with the same 'wtitle'
  6.     // to make sure the window is reused and refocused.
  7.     if (win && win.focus){ win.focus(); }
  8.     return false; // I do this here so the onclick is easier to read (for me anyway)
  9. }


then update your call to...
HTML Code:
Original - HTML Code
    <a href="http://www.ioforge.com/" target="TEST" onclick="return pop(this.href, this.target, 'width=650,height=650');"> <img src="URL/IMAGE" alt="ALT" class="thumb" /> </a>


this way, you put as much info in the original link as possible, and make the javascript function mirror this functionality (by calling the link's written parameters with 'this'). to be truly inobtrusive, we'd want to assign the onclick separately so that the link doesn't have an inline handler (I can show you how to do this too if you want). so now, without JS, the link still clicks, still opens a new window, and still loads relevant content. in fact, the only difference is that the JS function allows use of the 'props' var to make modifications to the layout of the popped window. this style should work like a champ in all browsers. good luck!

P.S. - note that jsKid's version still didn't return anything; he forced it to return false in the onclick by returning !pop(), which is in some ways preferable, since !anything (except false) is false, turning a null function into false. but on the other hand, it'll turn a false-returning function true, which might not do exactly what you'd like... so I just force the false in the function call itself so I can return it directly. really just a matter of preference.
__________________

"Human history becomes more and more a race between education and catastrophe." (H.G. Wells)
"Giving me a new idea is like handing a cretin a loaded gun, but I do thank you anyhow, bang, bang." (Philip K. D!ck)

Last edited by derelict : August 11th, 2008 at 02:33 PM. Reason: highlight your syntax, dummy

Reply With Quote
  #4  
Old August 11th, 2008, 03:48 PM
Matt1776's Avatar
Matt1776 Matt1776 is offline
Recovering Intellectual
Dev Shed Beginner (1000 - 1499 posts)
 
Join Date: Jun 2006
Location: Orange County, CA
Posts: 1,303 Matt1776 User rank is Major General (70000 - 90000 Reputation Level)Matt1776 User rank is Major General (70000 - 90000 Reputation Level)Matt1776 User rank is Major General (70000 - 90000 Reputation Level)Matt1776 User rank is Major General (70000 - 90000 Reputation Level)Matt1776 User rank is Major General (70000 - 90000 Reputation Level)Matt1776 User rank is Major General (70000 - 90000 Reputation Level)Matt1776 User rank is Major General (70000 - 90000 Reputation Level)Matt1776 User rank is Major General (70000 - 90000 Reputation Level)Matt1776 User rank is Major General (70000 - 90000 Reputation Level)Matt1776 User rank is Major General (70000 - 90000 Reputation Level)Matt1776 User rank is Major General (70000 - 90000 Reputation Level)Matt1776 User rank is Major General (70000 - 90000 Reputation Level)Matt1776 User rank is Major General (70000 - 90000 Reputation Level)Matt1776 User rank is Major General (70000 - 90000 Reputation Level) 
Time spent in forums: 1 Month 1 Week 1 Day 7 h 48 m 58 sec
Reputation Power: 784
Send a message via ICQ to Matt1776 Send a message via Skype to Matt1776
Thank you both for your suggestions, they were both illuminating and very helpful. Now I do see where I can make some changes and improvements.

One thing that was causing issues was the parameter for the window 'title', in my original code I was using a title such as: 'Ioforge Design Portfolio'. Now for some strange unknown reason javascript does not like spaces, and when by accident I removed those spaces the window launched just fine.

This does not explain the whole issue with my code, but it was another thing to be aware of. I will try out these different solutions when I am able, and let you guys know if I have any issues.

Reply With Quote
  #5  
Old August 11th, 2008, 04:42 PM
derelict's Avatar
derelict derelict is offline
garish grotesque gargoyle
Dev Shed Beginner (1000 - 1499 posts)
 
Join Date: Mar 2006
Location: gracing gargantuan gothic gateways
Posts: 1,337 derelict User rank is General 1st Grade (Above 100000 Reputation Level)derelict User rank is General 1st Grade (Above 100000 Reputation Level)derelict User rank is General 1st Grade (Above 100000 Reputation Level)derelict User rank is General 1st Grade (Above 100000 Reputation Level)derelict User rank is General 1st Grade (Above 100000 Reputation Level)derelict User rank is General 1st Grade (Above 100000 Reputation Level)derelict User rank is General 1st Grade (Above 100000 Reputation Level)derelict User rank is General 1st Grade (Above 100000 Reputation Level)derelict User rank is General 1st Grade (Above 100000 Reputation Level)derelict User rank is General 1st Grade (Above 100000 Reputation Level)derelict User rank is General 1st Grade (Above 100000 Reputation Level)derelict User rank is General 1st Grade (Above 100000 Reputation Level)derelict User rank is General 1st Grade (Above 100000 Reputation Level)derelict User rank is General 1st Grade (Above 100000 Reputation Level)derelict User rank is General 1st Grade (Above 100000 Reputation Level)derelict User rank is General 1st Grade (Above 100000 Reputation Level) 
Time spent in forums: 2 Weeks 6 Days 8 h 35 m 8 sec
Reputation Power: 1036
ok, gotcha....

that 'title' isn't a title at all -- it's the 'name' you give to that window instance... you use that 'name' if you want to re-use the same window again in the future. It is utterly invisible to the end user.

like most variable 'names', it doesn't like spaces. I bet you'd probably have problems with asterisks, ampersands, and starting the name with dashes or parens too.

to use a new window every time, use the word 'new' (or is it '_new' ?) -- I haven't had to spawn new windows in so long I kind of forget....

HTH - derelict

Reply With Quote
  #6  
Old August 11th, 2008, 05:13 PM
Kravvitz's Avatar
Kravvitz Kravvitz is offline
CSS & JS/DOM Adept
Dev Shed God 30th Plane (19500 - 19999 posts)
 
Join Date: Jul 2004
Location: USA
Posts: 19,893 Kravvitz User rank is General 48th Grade (Above 100000 Reputation Level)Kravvitz User rank is General 48th Grade (Above 100000 Reputation Level)Kravvitz User rank is General 48th Grade (Above 100000 Reputation Level)Kravvitz User rank is General 48th Grade (Above 100000 Reputation Level)Kravvitz User rank is General 48th Grade (Above 100000 Reputation Level)Kravvitz User rank is General 48th Grade (Above 100000 Reputation Level)Kravvitz User rank is General 48th Grade (Above 100000 Reputation Level)Kravvitz User rank is General 48th Grade (Above 100000 Reputation Level)Kravvitz User rank is General 48th Grade (Above 100000 Reputation Level)Kravvitz User rank is General 48th Grade (Above 100000 Reputation Level)Kravvitz User rank is General 48th Grade (Above 100000 Reputation Level)Kravvitz User rank is General 48th Grade (Above 100000 Reputation Level)Kravvitz User rank is General 48th Grade (Above 100000 Reputation Level)Kravvitz User rank is General 48th Grade (Above 100000 Reputation Level)Kravvitz User rank is General 48th Grade (Above 100000 Reputation Level)Kravvitz User rank is General 48th Grade (Above 100000 Reputation Level) 
Time spent in forums: 6 Months 2 Days 18 h 35 m 4 sec
Reputation Power: 4192
Quote:
Originally Posted by derelict
to use a new window every time, use the word 'new' (or is it '_new' ?) -- I haven't had to spawn new windows in so long I kind of forget....

'_blank' is used for that. An empty string might work too.

http://developer.mozilla.org/en/doc...w.open#Examples
Comments on this post
derelict agrees: mozilla and msdn say '_blank' which looks to have originally been a microsoft convention
__________________
Spreading knowledge, one newbie at a time. I'm available for hire at Dynamic Site Solutions.

Check out my blog. | Learn CSS. | PHP includes | X/HTML Validator | CSS validator | Common CSS Mistakes | Common JS Mistakes

Remember people spend most of their time on other people's sites (so don't violate web design conventions).

Last edited by Kravvitz : August 11th, 2008 at 05:16 PM.

Reply With Quote
Reply

Viewing: Dev Shed ForumsWeb DesignJavaScript Development > Window.open does not work in IE?

Developer Shed Advertisers and Affiliates



Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

© 2003-2013 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap