Click to See Complete Forum and Search --> : Javascript Hyperlink Problem
Yoshimi
10-12-2003, 04:14 AM
Hi, I'm a bit of a newbie, so hope I'm posting to the correct forum...
I have a bit of javascript which, when clicking a hyperlink creates a new window at the centre of the screen. This works wonderfully on all Apple Macs tested, but not on PC's.
Could someone tell me how to get the code working on both platforms?
The code is:
<a href=javascript:openCenterWin("http://www.homepage.mac.com/johntstuart/flash/flash.swf",800,450)">
Many thanks.
Khalid Ali
10-12-2003, 09:27 AM
use it like below and it should work for all
<a href="http://www.homepage.mac.com/johntstuart/flash/flash.swf" onclick="openCenterWin("http://www.homepage.mac.com/johntstuart/flash/flash.swf",800,450);return false;">
Yoshimi
10-12-2003, 01:37 PM
'fraid this didn't work (at least on a Mac), it just loads the SWF file in the present window.
AdamGundry
10-12-2003, 01:43 PM
Assuming your code for the openCenterWin function is correct, Khalid's solution is the best possible. It will load the page in a new window if Javascript is available, and if not it will use the current window.
Adam
Yoshimi
10-12-2003, 01:58 PM
I assure you it's not working. I've tried it on Safari and Internet Explorer on Mac.
Click on my WWW button below. The 'Portfolio' button at the top of the page has Khalid's code assigned to it.
AdamGundry
10-12-2003, 02:13 PM
Sorry, didn't look carefully enough. The quotes in the openCenterWin function call should be single, not double:
<a href="http://www.homepage.mac.com/johntstuart/flash/flash.swf" onclick="openCenterWin('http://www.homepage.mac.com/johntstuart/flash/flash.swf',800,450);return false;">
Adam
P.S. Of course, you shouldn't really be using popups to comply with accessibility standards.
Yoshimi
10-12-2003, 02:17 PM
Cheers, works on Mac, will test on PC tomorrow at college.
The flash site was designed specifically for a popup window. I think it looks much better like that.