1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

Link code to open new window without depreciated attributes

Discussion in 'HTML & Website Design' started by Josh Inno, Dec 20, 2006.

  1. #1
    I am currently trying to figure out how to open a link to a new page without using the depreciated attribute "target".
     
    Josh Inno, Dec 20, 2006 IP
  2. T0PS3O

    T0PS3O Feel Good PLC

    Messages:
    13,219
    Likes Received:
    777
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Is javascript an option?
     
    T0PS3O, Dec 20, 2006 IP
  3. mopacfan

    mopacfan Peon

    Messages:
    3,273
    Likes Received:
    164
    Best Answers:
    0
    Trophy Points:
    0
    #3
    What makes you think adding "target" affects the value of the link?
     
    mopacfan, Dec 20, 2006 IP
  4. T0PS3O

    T0PS3O Feel Good PLC

    Messages:
    13,219
    Likes Received:
    777
    Best Answers:
    0
    Trophy Points:
    0
    #4
    I think he just means it's not supported anymore by the W3 standards and he wants valid code. Not to do with SEO.
     
    T0PS3O, Dec 20, 2006 IP
  5. Josh Inno

    Josh Inno Guest

    Messages:
    1,623
    Likes Received:
    14
    Best Answers:
    0
    Trophy Points:
    0
    #5
    Correct. I'm trying to write to 4.01 strict, if possible. And no, at this time Javascript is not an option. I'm just hoping that there is a CSS equivalent, or a newer version of the tag that conforms to 4.01 strict. Otherwise, as my boss wants it to open in a new window, I will have to revert to transitional, which is not something I want to do if it can be avoided.
     
    Josh Inno, Dec 20, 2006 IP
  6. Lichurec

    Lichurec Peon

    Messages:
    61
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    0
    #6
    Shortly - there is none..

    It's supposed to be users / visitors decision, whether he / she wants particular link to be opened in new window / new tab / same window. Therefore - "target" has been deleted from newest versions of specifications.

    Web Designers should never "interact" with users / visitors web browsers' behaviour. And will not be able to / be allowed to - in most cases..
    Web designers should stick to the behaviour of their website and their content..

    Kindly regards,
    L.
     
    Lichurec, Dec 20, 2006 IP
  7. Josh Inno

    Josh Inno Guest

    Messages:
    1,623
    Likes Received:
    14
    Best Answers:
    0
    Trophy Points:
    0
    #7
    I agree with this completely, but have been over-ruled by those higher than me in rank.
     
    Josh Inno, Dec 20, 2006 IP
  8. Lichurec

    Lichurec Peon

    Messages:
    61
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    0
    #8
    So simply tell them - it "can not be done" and that "it's pointless"...
    What's more important - tell them that they will actually lose users / visitors IF they force them - users - to open new links in new windows (as they - owners - wish to) and not the way they - users - want to / are used to..

    Works in 99.99% (worked "always" when I was in such situation)..

    Kindly regards,
    L.
     
    Lichurec, Dec 20, 2006 IP
  9. Josh Inno

    Josh Inno Guest

    Messages:
    1,623
    Likes Received:
    14
    Best Answers:
    0
    Trophy Points:
    0
    #9
    The include which contains the target="blank" was given to me by my boss, who did the job before me.

    I do intend to have a conversation with the company owner/the boss that gave me the include about this, and the fact that however much he wants the user to use the web in a certain way, if he annoys users, our client will loose business.
     
    Josh Inno, Dec 20, 2006 IP
  10. kk5st

    kk5st Prominent Member

    Messages:
    3,497
    Likes Received:
    376
    Best Answers:
    29
    Trophy Points:
    335
    #10
    Mention to your boss that the target attribute is no longer valid; in other words, things have changed. But, good news! There is a way to do the same thing that is valid and degrades gracefully. :D
    
    <a href="some.html"
       onclick="return !window.open(this.href);">somewhere</a>
    Code (markup):
    If the user has javascript enabled, a new window opens, and the html link does not fire. If javascript fails for some reason or the user does not have javascript enabled, the html link fires normally.

    It is a trivial matter to move the javascript out of the html, and attach the onclick event handler unobtrusively.

    cheers,

    gary
     
    kk5st, Dec 20, 2006 IP
  11. Josh Inno

    Josh Inno Guest

    Messages:
    1,623
    Likes Received:
    14
    Best Answers:
    0
    Trophy Points:
    0
    #11
    He could care less about transitional vrs strict. He uses Dreamweaver, and is still building pages. In fact, he could care less that "name" is no longer a valid attribute for most tags, but told me that I can leave that till later, and to just get it done. At this point, getting it done is at the top of my priority list as well. I've taken way longer than I should have, due to the fact that CSS didn't exist the last time I coded for a webpage, and the client is strongly considering moving to a different hosting company.

    He's the boss, and I'll make the page how he wants it made, but I will try to get it as close to standard as possible while doing so. And thank you kk5st for the standards way of doing what he wants done... so long as it doesn't slow me down and risk us loosing the client. I can go back and make the code -better- later so long as it -works- now.

    And again, he's the boss. If he orders me to write code without CSS, using the original version of HTML with nothing but a hammer, chisel, and a block of stone, that's what I'll do. Fortunately, I have a PC with 2 monitors, a full Gig of memory, and am allowed to use my beloved gVIM, in addition to having Dreamweaver to help me pick apart other people's web-pages and find the relevant code to find out how things were done (I don't steal the web pages, just learn from the code on them of course). He has also given me the discretion to do the code however I please so long as the results are the ones he wants. This has lead to me getting this page up to standard, minus the include, which he has allowed me to change (so long as it still does what he wants), and a few page-specific bugs I'm working out. And this is my first tech-job since 2002, and that one was a student-worker job, and I'm still on probation here. So I'm graetful.

    Also, as yet another reason for not following the 'how to handle your boss' advice... he knows my user name, and reads this forum, so following your advice and telling him 'no, you can't do that' when you've already said I can, can get me fired for lying.
     
    Josh Inno, Dec 21, 2006 IP
  12. Josh Inno

    Josh Inno Guest

    Messages:
    1,623
    Likes Received:
    14
    Best Answers:
    0
    Trophy Points:
    0
    #12
    Also, it's possible that there are reasons my boss has chosen to do this that I am missing.
     
    Josh Inno, Dec 21, 2006 IP
  13. johnnyblotter

    johnnyblotter Peon

    Messages:
    32
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #13
    hmmm. I'm probably missing something here. Why is javascript not an option? Your problem is settled in two minutes and the code will still validate.
     
    johnnyblotter, Dec 21, 2006 IP
  14. Josh Inno

    Josh Inno Guest

    Messages:
    1,623
    Likes Received:
    14
    Best Answers:
    0
    Trophy Points:
    0
    #14
    Well, it's because -I- was under a misconception. I thought I'd have to install stuff server side, and set up all sorts of codes, and that if the user didn't have java installed, that it would break the page or the link.

    I was not aware that the java not being there would just cause the link to open normally. Mea Culpa.
     
    Josh Inno, Dec 21, 2006 IP
  15. Josh Inno

    Josh Inno Guest

    Messages:
    1,623
    Likes Received:
    14
    Best Answers:
    0
    Trophy Points:
    0
    #15
    Well, I just tried the java solution, and it didn't work.

    I'm down to this, and specifying the number of form rows and columns and I'll have the page in standard.
     
    Josh Inno, Dec 21, 2006 IP
  16. kk5st

    kk5st Prominent Member

    Messages:
    3,497
    Likes Received:
    376
    Best Answers:
    29
    Trophy Points:
    335
    #16
    Josh,

    Java ≠ javascript (ECMAScript).

    Show us a snippet of the not-working link with javascript. If the browser has javascript enabled, it does work. So either the js is dead, or there's an error in the code.

    cheers,

    gary
     
    kk5st, Dec 21, 2006 IP
  17. Lichurec

    Lichurec Peon

    Messages:
    61
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    0
    #17
    Just a quick note:
    I don't think anyone said that "you can't do that"... we just mentioned that "you can't do that" the way you wanted / mentioned above and keep the code 100% Strict!

    Problem with JS (and as it has already been mentioned - JavaScript is not the same as Java) is that most so called "Advanced Users" (AU) have JS disabled while surfing @ "unknown" website.. so opening links in new window with JS won't affect them..

    And once more - there's the "ideology" problem.. Ask anyone hep enough (knowing what Web Standards are / following netiquette /
    coding "for users" not "for web site owners") and he/she will tell you that it's up to users' decision - how to open links; and that it's not webmasters' decision on how should web browser interact with website (like window-resizing, window-movement, webbrowsers' skin / colour change, background-sound played at load, pop-outs not on demand, etc..)

    Kindly regards,
    L.
     
    Lichurec, Dec 21, 2006 IP
    kk5st likes this.
  18. Josh Inno

    Josh Inno Guest

    Messages:
    1,623
    Likes Received:
    14
    Best Answers:
    0
    Trophy Points:
    0
    #18
    Sorry, I thought I was being told to tell my boss that you can't open a link in a new window.

    The strict is my concern, not his, and at this point that's fading relative to 'get it done'.

    Also, the Ideology differs here. My boss's philosophy is that we spend a lot of money, and effort, to get people to go to the site, so popping open a new window when we link them to a map on how to get to the client's office, rather than having them navigate away with a single click is a -good- thing. I am annoyed by it, but I've been asking people I know that are a part of the target demographic for this business, and if they even notice it popping up, they either don't care, or see it as a service.

    Now, my personal page I'm planning is going to be 100% strict code, will have no browser 'forces' and will be designed to be accessible. The client's website will be built according to the client's needs, and the needs of the client's target demographic.

    Personally, I see the fact that 'advanced' users would have js turned off as an advantage, as then those 'advanced' users would not be annoyed by the link opening in a new window automatically.

    I'll re-post the link after I re-insert the java-code, I took it back out as the client will be seeing the site later.
     
    Josh Inno, Dec 22, 2006 IP
  19. Josh Inno

    Josh Inno Guest

    Messages:
    1,623
    Likes Received:
    14
    Best Answers:
    0
    Trophy Points:
    0
    #19
    I just went over the code provided above, and tried it again, and the reason it didn't work was a misconception on my part. I thought that "this.href" was something I was supposed to replace with the actual link, similar to the "some.html" placeholder. When I left it in everything worked fine.

    Now, just to make sure I understand you right, since Javascript != Java, even if they don't have Java installed, the link would still work, unless they had Javascript disabled?

    And thanks again for all the help!
     
    Josh Inno, Dec 26, 2006 IP
  20. kk5st

    kk5st Prominent Member

    Messages:
    3,497
    Likes Received:
    376
    Best Answers:
    29
    Trophy Points:
    335
    #20
    Lichurec may have overstated the portion of "advanced users" with js disabled, but the gross numbers are on the order of 10% disabled. The largest group are corporate users, where there the IT dept. has it disabled&#8212;often at the firewall, stripping out the code. Anyone using IE on the web with ActiveX enabled is courting disaster. In IE, disabling ActiveX also kills js.

    Power users tend not to like automatic new windows, because it adds another window to what may be an already overcrowded desktop. Less experienced users tend to run their browser maximized, not realizing a new window is covering the old. "Why doesn't my #&^% back button work?!"

    Javascript (technically ECMAScript) does not require a plug-in. It is generally native to graphical browsers. Do keep in mind that most assistive technologies, eg., screen readers or Braille pads, &c., do not support javascript (or the target attribute, either). If accessibility is an issue for your employer, the method I gave you degrades gracefully.

    cheers,

    gary
     
    kk5st, Dec 26, 2006 IP