Jump to content

window:open() question


SmokingMan

Recommended Posts

I want to use the .open() method to open new windows depending on the link clicked by the user. How do I change the URL parameter in the method depending on the link clicked, or do I need to set up a separate function for each link? I would think there would have to be a way to use one function and modify it for each link as needed. Or maybe use an if...else structure for the links?I'm open to suggestions.

Link to comment
Share on other sites

why are you using javascript for this? your making it way harder than it is..<a href="http://my.url.com" target="_blank">some link</a>taadaa!

First off target is deprecated (except in frames, so i read)Second, maybe he wants to open the window with certain dimensions and some toolbars disabled.
Link to comment
Share on other sites

why are you using javascript for this? your making it way harder than it is..<a href="http://my.url.com" target="_blank">some link</a>
I'm using JS because the "target" attribute has been deprecated. It may still work in all browsers, but it doesn't validate as XHTML Strict. This script will open a slideshow and I just want the window large enough to contain the show, so I have to control how the window displays.
Link to comment
Share on other sites

Okay...here goes. Here's the script I'm using:

function	openShow(url)	{window.open('url',location=0,height=450,width=500,left=200,top=50,menubar=0,resizable=0,scrollbars=0,status=0,toolbar=0);	}

And here's the link I'm trying to open:

<tr><td class="menu"><a href="http://testdomain.ftwin.com/albums/missy/missy-slideshow.html" class="child1" 					onmouseover="return addressMsg('Missy\'s Photo Slideshow')" onmouseout="return addressMsg('')"					onclick="openShow('http://testdomain.ftwin.com/albums/missy/missy-slideshow.html');return false;">Missy's Slideshow</a></td></tr>

In IE it opens a new window, but it opens as a full screen window with all of the attributes. All of my restrictions are ignored, and it's not a new separate window like I want it to be.In FF I get two new windows, but both have error messages. The first one opens to my specifications, with this message:

Not FoundThe requested URL /url was not found on this server.Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request.

The other window is a new full screen window with this message:

Not FoundThe requested URL /0 was not found on this server.Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request.

That's two windows with different errors. I haven't tried Opera yet, I'm afraid to see what happens there. Any ideas?If you want to try it, here's the link to the page. You'll want to go to Missy's Slideshow under Slideshows.

Edited by SmokingMan
Link to comment
Share on other sites

Try this, window.open should have 3 parameters and if they are not variables be enclosed within quotes.window.open(url,""," location=0,height=450,width=500,left=200,top=50,menubar=0,resizable=0,scrollbars=0,status=0,toolbar=0")

Link to comment
Share on other sites

Well that worked...mostly. I now get the new separate window to open with my parameters, but the same window also opens in the current browser. So you end up with two browser windows open with the same page, but one is the first browser and the other is the one that conforms to the .open() parameters.I think I figured it out. I have the URL in the href attribute in the <a>...</a> and also in the onclick event. But if I remove it from the href, will the onclick still work if JS is disabled?

Edited by SmokingMan
Link to comment
Share on other sites

That's weird, it worked ok for me.Make sure you have;onclick="openShow('http://testdomain.ftwin.com/albums/missy/missy-slideshow.html');return false;"

I think I figured it out. I have the URL in the href attribute in the <a>...</a> and also in the onclick event. But if I remove it from the href, will the onclick still work if JS is disabled?
Yeah that's because if the user has js disabled they can still access the page with html, so if you remove it they wont see anything. Edited by scott100
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...