www.webdeveloper.com
Results 1 to 7 of 7

Thread: Javascript Hyperlink Problem

  1. #1
    Join Date
    Oct 2003
    Location
    Edinburgh, UK
    Posts
    4

    Javascript Hyperlink Problem

    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.

  2. #2
    Join Date
    Dec 2002
    Location
    Calgary, Canada
    Posts
    6,123
    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;">
    Cheers

    Khalid

    Message Posting Guidelines In These Forums, Please read these before posting any question.
    Web site: webapplikations.com
    Web Resources Page:Web Resources

  3. #3
    Join Date
    Oct 2003
    Location
    Edinburgh, UK
    Posts
    4
    'fraid this didn't work (at least on a Mac), it just loads the SWF file in the present window.

  4. #4
    Join Date
    Nov 2002
    Location
    Dartmoor [Holiday]
    Posts
    2,382
    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
    "If youíre not using valid HTML, then you havenít created a Web page. You may have created something else, but it isnít a Web page." - Joe Clark

    Do something amazing (USA) | Make Poverty History

  5. #5
    Join Date
    Oct 2003
    Location
    Edinburgh, UK
    Posts
    4
    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.

  6. #6
    Join Date
    Nov 2002
    Location
    Dartmoor [Holiday]
    Posts
    2,382
    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.
    "If youíre not using valid HTML, then you havenít created a Web page. You may have created something else, but it isnít a Web page." - Joe Clark

    Do something amazing (USA) | Make Poverty History

  7. #7
    Join Date
    Oct 2003
    Location
    Edinburgh, UK
    Posts
    4
    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.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles