Results 1 to 5 of 5

Thread: offsite links Resolved

  1. #1
    Join Date
    Feb 2009
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default offsite links Resolved

    http://www.dynamicdrive.com/dynamici...newwindow2.htm

    Is it possible to change this script in a manner that it opens all links in a new window? So even if they are of my own domain.
    Now I am using the "target="_blank" syntax, but W3C does not like "target"
    When using this script, W3C does not complain.
    Last edited by FredPitt; 02-12-2009 at 12:57 PM.

  2. #2
    Join Date
    Oct 2008
    Location
    Sweden
    Posts
    2,023
    Thanks
    17
    Thanked 319 Times in 318 Posts
    Blog Entries
    3

    Default

    Just make sure your site is not mentioned here:
    Code:
    //1)Enter domains to be EXCLUDED from opening in new window:
    excludedomains: ["dynamicdrive.com", "google.com"],
    Good luck!

  3. #3
    Join Date
    Sep 2005
    Location
    India
    Posts
    1,627
    Thanks
    6
    Thanked 107 Times in 107 Posts

    Default

    I have changed the assigntarget function and furnished below. Comment the default one and insert this one.

    Code:
    assigntarget: function() {
    		var rexcludedomains = new RegExp(this.excludedomains.join("|"), "i") var all_links = document.getElementsByTagName("a") if (this.mode == "auto" || (this.mode == "manual" && this.togglebox.checked)) {
    			for (var i = 0; i <= (all_links.length - 1); i++) {
    				if (all_links[i].hostname.search(rexcludedomains) == -1 && all_links[i].href.indexOf("http:") != -1) 
    					if (ddwindowlinks.linktarget === '_blank') {
    						all_links[i].removeAttribute('target');
    						all_links[i].onclick = function() {
    							window.open(this.href, "");
    							return false;
    						};
    					}
    			}
    		} else {
    			for (var i = 0; i <= (all_links.length - 1); i++) all_links[i].target = ""
    		}
    		if (this.mode == "manual" && this.persist) this.setCookie("dlinktarget", (this.togglebox.checked) ? "yes": "no", 30) //remember user setting for 30 days (set to -1 then reload page to erase cookie)
    	}
    At the moment I haven't used any of the parameters that can be used while opening a new window. You can use them based on your requirement.

    Hope this helps.

  4. #4
    Join Date
    Feb 2009
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    You are right, but I did not mention my domain there.
    But your answer made me understand what was wrong:
    The link (to a page of my domain) referred directly to it`s place on the host.
    In that case it opens in the same window.
    Now I changed it to it`s complete internet address and it opens in a new window. Problem solved, thanks!

  5. #5
    Join Date
    Oct 2008
    Location
    Sweden
    Posts
    2,023
    Thanks
    17
    Thanked 319 Times in 318 Posts
    Blog Entries
    3

    Default

    You're welcome, glad to help!
    You can go to your first post in this thread, click then click Go Advanced and add the Resolved prefix to the thread title.
    This will let other users know the problem has been solved.

    Good luck with your site!

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
  •