SitePoint Sponsor

User Tag List

Results 1 to 4 of 4

Hybrid View

  1. #1
    SitePoint Member
    Join Date
    Nov 2002
    Posts
    5
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    CSS problem with window.open()

    My css file says:
    a:visited, a:link {
    color: Green;
    text-decoration:none
    }


    If I make a normal link with <a href= etc,etc/> it works fine but, if I do it like follows:

    <a onclick=window.open("Volver.htm","","height=600,width=250,left=80,top=80")>Volver</a>

    The link works fine but, it does not look linked as my css says.

    Anybody help!

    C@rlos
    EL MARIACHI ES CULTURA

  2. #2
    Web-coding NINJA! silver trophy beetle's Avatar
    Join Date
    Jul 2002
    Location
    Dallas, TX
    Posts
    2,900
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    <a href="Volver.htm" onclick="window.open(this.href,'','height=600,width=250,left=80,top=80'); return false;">Volver</a>
    beetle a.k.a. Peter Bailey
    blogs: php | prophp | security | design | zen | software
    refs: dhtml | gecko | prototype | phpdocs | unicode | charsets
    tools: ide | ftp | regex | ffdev




  3. #3
    SitePoint Member
    Join Date
    Nov 2002
    Posts
    5
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Lightbulb

    Thanks a lot dude!

    I did solved it as follows:

    <a href="javascript:;" onclick=window.open("Volver.htm","","height=600,width=250,left=80,top=80")>Volver, volver</a>

    It is important to include both the colon and the semicolon.
    Note: You can instead use a number sign (#) in the link if you want. The problem with using a number sign is that when a visitor clicks the link, some browsers may jump to the top of the page. Clicking the JavaScript null link has no effect at all on the page, so the JavaScript approach is generally preferable.




    C@rlos
    EL MARIACHI ES CULTURA

  4. #4
    Web-coding NINJA! silver trophy beetle's Avatar
    Join Date
    Jul 2002
    Location
    Dallas, TX
    Posts
    2,900
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Yes, but the method I inserted is more prefereable than either of yours for these reasons:

    1) Degrades
    2) Links work even if user has javascript turned off
    3) Search engines can still spider your links

    Using an empty javascript:; is a hack at best, and certainly not preferred IMHO. But if you must, use this instead:

    <a href="javascript://" ... >link</a>
    beetle a.k.a. Peter Bailey
    blogs: php | prophp | security | design | zen | software
    refs: dhtml | gecko | prototype | phpdocs | unicode | charsets
    tools: ide | ftp | regex | ffdev





Bookmarks

Posting Permissions

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