SitePoint Sponsor

User Tag List

Page 2 of 2 FirstFirst 12
Results 26 to 48 of 48
  1. #26
    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)
    This will work
    Code:
    function blankLinks()
    {
       var o = ( document.all ) ? event.srcElement : e.target;
       if ( o.nodeName != 'A' ) return;
       o.target = "_blank";
    }
    And then
    HTML Code:
    <table id="theseLinks" onclick="blankLinks()">
    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




  2. #27
    SitePoint Wizard Bill Posters's Avatar
    Join Date
    Dec 2001
    Location
    UK
    Posts
    1,523
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    do I take it from the presence of document.all that the only solution available is exclusive to IE?
    New Plastic Arts: Visual Communication | DesignateOnline

    Mate went to NY and all he got me was this lousy signature

  3. #28
    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)
    No - just a sniffer test to grab the correct event object and property. I could probabaly also use

    if ( event )

    as well, which would probably be a bit better.
    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




  4. #29
    SitePoint Wizard Bill Posters's Avatar
    Join Date
    Dec 2001
    Location
    UK
    Posts
    1,523
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    At the risk of showing my ignorance-

    can you show me the 'better'* version you mention?
    (* presumably 'better' means standards-compliant or at least not IE-specific)

    TIA again

    ---

    is there also a way to specify that all links pointing to a domain other than the host domain will open in new windows?

    This is a 'Plan B' idea that may actually be more appropriate for the situation I have in mind.

    TIA again (again)
    Last edited by Bill Posters; Jul 2, 2003 at 02:21.
    New Plastic Arts: Visual Communication | DesignateOnline

    Mate went to NY and all he got me was this lousy signature

  5. #30
    Don't eat yellow snow spaceman's Avatar
    Join Date
    Mar 2001
    Location
    Melbourne, Australia
    Posts
    1,039
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Oops - javascript ignorance problem!

    Just tried to combine Kev's New-Window Links javascript code with the javascript code in his recent Tech Times article on 'Equalizing Column Heights' (http://www.sitepoint.com/newsletter/...d=3&issue=70#7)

    But the two together aren't working :-( It's a case of one or the other but not both.

    My semi-educated guess is that it's because both functions use 'window.onload' - I've tried combining them in various combinations but no luck yet.

    Any takers?
    Web Design Perth Melbourne .:. Itomic Business Website Solutions
    Drupal Experts .:. Drupalise

  6. #31
    ☆★☆★ silver trophy vgarcia's Avatar
    Join Date
    Jan 2002
    Location
    in transition
    Posts
    21,235
    Mentioned
    1 Post(s)
    Tagged
    1 Thread(s)
    Maybe create a function to wrap the two you're currently using, and run that during the onload event?
    Code:
    <script type="text/javascript">
    function wrapTwo() {
      functionOne();
      functionTwo();
      //replace this with the name of your functions.
    }
    window.onload = wrapTwo();
    </script>

  7. #32
    Anonymous
    SitePoint Community Guest
    No, you can't be serious? Links should be made to work both WITH and WITHOUT JavaScript! See:
    http://evolt.org/article/rating/17/20938/
    If the new, strict HTML standard has actually removed to possibility to open new windows, then this is an outrage! Totally unacceptable!
    /Carl Lindmark

  8. #33
    Anonymous
    SitePoint Community Guest
    Thanks for your article. It really helped get things into perspective. I made use of your external="rel" method and it worked great. Then I had an idea, what if the script could just make all off-site links open in a new window, without having to specify the rel="external"? So I <a href="http://www.fastmedia.com/hacks/xhtml-target.js.txt">put this together</a>. Seems to work ok in IE, Mozilla, and Netscape 4.0 (my personal favourite). Be interested to hear if anyone has any problems with it. --cpaul

  9. #34
    Anonymous
    SitePoint Community Guest
    I've been meaning to convert all my external links to XHTML strict compatibility, but never got around to doing it. Thanks for saving me the effort! It works like a charm.

  10. #35
    Anonymous
    SitePoint Community Guest
    Doesnt work with <a rel="enternal href= "http://blah.blah.com">

  11. #36
    SitePoint Wizard Bill Posters's Avatar
    Join Date
    Dec 2001
    Location
    UK
    Posts
    1,523
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    <a rel="enternal href= "http://blah.blah.com">
    Why would it? What's enternal? And why haven't you closed the quotes around the rel value? And what's with the space after href=?

    See where this is going?
    New Plastic Arts: Visual Communication | DesignateOnline

    Mate went to NY and all he got me was this lousy signature

  12. #37
    Anonymous
    SitePoint Community Guest
    Maybe create a function to wrap the two you're currently using, and run that during the onload event? function wrapTwo() { functionOne(); functionTwo(); //replace this with the name of your functions. } window.onload = wrapTwo();

    aff dan

  13. #38
    Anonymous
    SitePoint Community Guest
    Isn't it looks terrible for you, when W3C saying to what yous should do? It's really stupid in their case, removing target attribute from HTML should call changes in scripting languages too, because they built to support anchor.target for specifying target of the URI. So, as developer, i can see the situation where W3C got no cooperation with real development world ans stucked with stupid recomendations (W3C recomends standarts and you have a choice to accept them or not) and motivation that using targets is old fashioned is not the best one...

  14. #39
    Anonymous
    SitePoint Community Guest
    Why not use something as simple as this: <a href="http://validator.w3.org/check/referer" class="validate" onclick="javascript: this.target='_blank';">

  15. #40
    SitePoint Wizard Bill Posters's Avatar
    Join Date
    Dec 2001
    Location
    UK
    Posts
    1,523
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Fine, if you only have one link.
    Any more than than, then it's better to control the effect remotely rather than have to sift through your markup implementing and/or replacing every instance individually.

    Personally, I'd see the best use of the "New Windows... method as looping through the links and attributing a _blank target to those links with a fully qualified url (i.e. those necessarily including the http:// string).
    It would then do away with the need to implement the rel attributes manually - something that isn't always possible if the links are brought in via a CMS or something similar.

    Another handy alternative would be to target links that fall within an element of a given id or class. That would also enable links within imported CMS data to be given the _blank target attribute by way of giving the parent div (or divs) a specific id or class.


    removing target attribute from HTML should call changes in scripting languages too, because they built to support anchor.target for specifying target of the URI.
    The point is that they are attempting to wittle down X/HTML to a scheme that can function on the most basic forms of browsers. Many alternative browsers don't have javascript enabled. Many users will disabled javascript for a variety of reasons. Many alternative browsers simply will not support multiple windows.
    BY reducing the markup to a broadly effective set of rules the same markup can be used across multiple platforms with additional features added via (.e.g.) javascript for use with those platforms that support it.
    This is the way that many/all 'extras' will (and should, imho) be handled.
    Given that scripting is easier to allow/prevent in a discretionary manner, users are given the choice whether or not to allow certain 'added' features such a whether they wish to browse using one window or many.
    So the point is not to remove them altogether, but just to move responsibility for them away from the basic markup.
    Understanding this move simply requires one to accept that multiple-window browsing is not in itself an intrinsic part of the browsing experience. Once you have your head around that, then it's easy to appreciate why extras such as that are gradually being farmed out to additional, platform-specific technologies.


    [aside]
    One inconsistency is that although the target attribute has been removed from XHTML 1.0 Strict, there still exists a W3C XHTML endorsement of frames (XHTML Frameset).
    Given that the W3C appear to be willing to carry framesets along for the ride, how are developers supposed to use them properly when the pages within the will ideally be using XHTML Strict (i.e. with no target attribute)?
    Or is the frameset DTD another of those 'slow lane'models meant purely for use with Transitional DTDs?
    I use neither framesets nor Transitional DTDs so, as an outsider, I may well be missing the point.
    [/aside]


    Off Topic:


    What's with all the posts made under 'Anonymous' logins?
    Have I missed a new SPf policy broadcast?
    Am I the only one seeing that?

    It makes quoting previous posts a bit hit 'n' miss.
    New Plastic Arts: Visual Communication | DesignateOnline

    Mate went to NY and all he got me was this lousy signature

  16. #41
    Anonymous
    SitePoint Community Guest
    Although the target attribute is part of the DOM this solution results in not really valid xhtml. doesn't matter which way you chose to use the target-attribute (inline or via JavaScript/DOM) - it's not part of the xhtml-strict standard!
    The only difference between this and using >>target="_blank"<< is, that the W3-Markup-Validator doesn't see this error and so it can't be displayed.
    The only standardized way to create new-window-links within xhtml-strict is to wait for CSS3 which has it's own standarized solution.

    Moe

  17. #42
    SitePoint Wizard Bill Posters's Avatar
    Join Date
    Dec 2001
    Location
    UK
    Posts
    1,523
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Why wait?
    Use it to trigger a window.open command.

    I appreciate the point about the script method of adding a target attribute being counter to the notion of deprecating it from markup in the first place.
    However, given that target is still a valid part of the W3C DOM (and isn't slated for deprecation, afaik*), it comes down to pedantry and sympathy as which DOM method you use to achieve a new window.
    The point was/is to move that kind of functionality out of markup and into other, more user-controllable, technologies.

    I don't see a conflict between that ideal and the current ability to create new windows (via a number of ways) using js.
    Given also that neither CSS(3) or js are "within xhtml-strict", I'd suggest that each is as good as the other for this purpose.
    (That said, I'm far from convinced about the wisdom of populating a style/presentation language (CSS) with functionality features when js already does a perfectly good job of handling that stuff.
    Placing 'new window' abilities in CSS3 is a wrong turn, imho.)

    (* I'm open to correction)


    Off Topic:



    Again, what is going on with these "Anonymous" user postings?
    Admins? Mods? Anyone wanna take this question?

    New Plastic Arts: Visual Communication | DesignateOnline

    Mate went to NY and all he got me was this lousy signature

  18. #43
    Anonymous
    SitePoint Community Guest
    This could work with very little effort for browsers that don't support document.getElementsByTagName by simply accessing the links collection (anchors is a misleading variable name), rather than simply causing aberrant behaviour by ignoring those browsers.

  19. #44
    Anonymous
    SitePoint Community Guest
    Are DOM-Standards controlled by the W3C too? If so, won't they be phasing out the target attribute in the future anyway?

    Plus isn't the point of web standards there to enable the user to choose how they wish to follow a link?

    I just think that this is, although helpful to those who still think that the web designer should have control over the experience, a bit too much extra work to be even bothered with.

  20. #45
    SitePoint Wizard Bill Posters's Avatar
    Join Date
    Dec 2001
    Location
    UK
    Posts
    1,523
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    It's not a question of wanting to get rid of new windows everywhere, just creating a more basic markup language than can be used across different mediums.
    They are simply trying to strip out the functions of markup that are unlikely to ever make it into the more basic alternative browsers.
    The javascript method will almost certtainly still be supported and built upon so long as there are still browser forms that (arguably) benefit from such a function.

    As said before, by farming the functionality of new windows out to script, the user will have more control over whether to accept or deny that feature.

    It's a case of being tidy-minded and at the same time, giving the final word back to the user.
    New Plastic Arts: Visual Communication | DesignateOnline

    Mate went to NY and all he got me was this lousy signature

  21. #46
    Free your mind Toly's Avatar
    Join Date
    Sep 2001
    Location
    Panama
    Posts
    2,181
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Bill Posters
    Off Topic:


    Again, what is going on with these "Anonymous" user postings?
    Admins? Mods? Anyone wanna take this question?
    Off Topic:


    Each article provides a form for comments at the bottom of the last page. When using that form, you have the option to use your forum username or post as an anonymous user in case you don't have an account or just don't want to use it. Every comment becomes a post in the thread created for the respective article.
    Community Guidelines | Community FAQ

    "He that is kind is free, though he is a slave;
    he that is evil is a slave, though he be a king." - St. Augustine

  22. #47
    SitePoint Wizard Bill Posters's Avatar
    Join Date
    Dec 2001
    Location
    UK
    Posts
    1,523
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Ahaa, cheers for filling in the gaps, Toly

    Nice idea re: the form, but not sure it's a great idea to allow anonymous posting access to the SPf boards, mostly for practical reasons.

    Responding to a raft of faceless posts is far less appealing than knowing who you are responding to and/or helping.
    It makes it significantly more difficult to appreciate what the anonymous poster understands about the issue - from their involvement in this thread, other threads at SPf and discussions elsewhere.
    It's hard to keep track of which anonoymous poster knows what and whether they have already participated with an earlier post.
    (I notice that I've already found myself repeating a point made by myself further up the thread.)


    On a more immediate note, perhaps changing 'Anonymous' user name to something like 'Article Comment' might make more sense to those, such as myself, who are inclined not to notice the 'reader comment' form at the end of each article.


    :everylittlehelps:
    New Plastic Arts: Visual Communication | DesignateOnline

    Mate went to NY and all he got me was this lousy signature

  23. #48
    Free your mind Toly's Avatar
    Join Date
    Sep 2001
    Location
    Panama
    Posts
    2,181
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Yes, I have to admit that the first time I saw an anonymous user I was confused.

    You may want to post your suggestion in the Suggestions and Feedback forum.
    Community Guidelines | Community FAQ

    "He that is kind is free, though he is a slave;
    he that is evil is a slave, though he be a king." - St. Augustine


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
  •