Forum Moderators: open
I have HTML code for clicking on a graphic to open a page in new window, and I have HTML code for an image rollover... but I can't work out a way to combine them. Is there a way to use JavaScript to open a custom window AND have an image rollover on the same button?
Many thanks :O)
The two pieces of code I have are:-
- OPENS WINDOW -
<INPUT TYPE="image" SRC="image.gif" VALUE="" onClick="window.open('index.html','ie', config='width=960,height=580,toolbar=no,menubar=no,scrollbars=yes,resizable=yes,location=no,directories=no,status=yes')" width="190" height="27">
- IMAGE ROLLOVER -
<a href="index.html" onmouseover="document.jump.src='image-on.gif'" onmouseout="document.jump.src='image-off.gif'"><img src="image-off.gif" name="jump" width="190" height="27"></a>
Your code worked perfectly... until I adjusted the formating around the button. The rollover still works, and it creates a window, but it can't find the page :O(
I have changed "page.html" to the true page address and I've checked that the page is still available. Now I'm sure it's something I've done, but do you have any futher suggestions, thanks :O)
Sure. Show more of your code.
Comment: I don't think config='status=yes' is right. I think that the 3rd arg of open() is just 'status=yes' (or whatever auxiliary window features you want -- a single, quoted string).
Actually, I'm surprised that the config= is not provoking an exception.
Edit: Opps. Another brain fart. config='status=yes' is simply doing an assignment within the call. A bit unusual approach but nothing to hurl chunks over.
[edited by: MarkFilipak at 1:08 am (utc) on Mar. 14, 2008]
The full code (with only the URL changed for "foo") is:-
<a href="#" onclick="window.open('http://www.foo.com/','ie', config='width=960,height=580,toolbar=no,menubar=no,scrollbars=yes,resizable=yes,location=no,directories=no,status=yes')"><img src="ie08-window-r.gif" name="newwin" ALT="Open this site in a window" NAME="Open this site in a window" border="0" width="190" height="27" onmouseover="document.newwin.src='ie08-window-r-on.gif'" onmouseout="document.newwin.src='ie08-window-r.gif'"></a>
The problem I want to solve is:-
A) Image button which opens a new window.
B) Image button that changes with some kind of mouse over.
C) Works smoothly with all broswers, or as smooth as possible.
I can do A, B, and now A+B, but not A+B+C :O(
P.s.
I did get the code suggested by HTTPWebWitch to work for a breif time.
I don't know how it could not work. He had your A, B and C, right there. And your code also works fine, as well.
Could there be something about the page to which you link? If not, the thing about a spawned window, like this, is that if you have popup blockers running - they're going to try to prevent it. There are plugins and ways to try to prevent image loading, or various flash ad loading, scripts of course (Noscript, for Firefox) and so on. So if you have a page with that, the addons and builtins will kick in.
In some configurations, the OS is setup NOT to spawn new windows. If you need both open at the same time, you might have to reconsider your method. You could use iframes, even though these are supposed to have fallen out of favor. Just creating a generic, object, using a couple of curly brackets ("{ }") and assigning the page at, "data", instead of "src" might be a substitute, and so on. You keep both on the same page, that way, or what they call the client area now the, 'viewport'.
The extjs folks have even taken the browser viewport to the point of trying to mimic a desktop OS, in the browser.