dcsimg
www.webdeveloper.com
Results 1 to 7 of 7

Thread: How can i remove the"www." header when i copy an address from the location bar

  1. #1
    Join Date
    Jul 2014
    Posts
    5

    How can i remove the"www." header when i copy an address from the location bar

    javascript:void(location.href='http://www.urlvoid.com/scan/'+encodeURI(window.location.host));

    can someone please modify the above script so that it can copy the address in the location bar without the WWW header.

    thanks in advance.

  2. #2
    Join Date
    Dec 2015
    Posts
    87
    Hey,check this,hope you get the idea:
    " https://developer.mozilla.org/en-US/...b/API/Location "

  3. #3
    Join Date
    Dec 2015
    Location
    India
    Posts
    82
    try this

    javascript:void(location.href='http://www.urlvoid.com/scan/'+encodeURI(window.location.hostname));

  4. #4
    Join Date
    Jul 2014
    Posts
    5
    thanks for replying
    i checked the mozilla site, i tried both "location.host" & "location.hostname" none of them were able to remove the "www." header , is there another way

  5. #5
    Join Date
    Jul 2014
    Posts
    5
    thank you for replying , i tried "location.hostname" it did not remove the "www." header, it only removes the "http://"
    i tried to use "location.href.replace" to replace the "www." header to remove it but i couldn't figure it out.

    i found the following script online, & im trying to figure how to add it to the previous script so it can remove "www." & then copy the URL

    (the script for replacing "www.")
    Code:
    javascript:void((function(){location.href=location.href.replace%20%20(%22www.%22,%%22);})())
    My script
    Code:
    javascript:void(location.href='http://www.urlvoid.com/scan/'+encodeURI(window.location.hostname));

  6. #6
    Join Date
    Sep 2015
    Posts
    95
    did you try this?

    Code:
    javascript:void(location.href='http://www.urlvoid.com/scan/'+encodeURI(window.location.host.replace("www.","")))
    Last edited by benmartin101; 01-18-2016 at 05:57 PM.

  7. #7
    Join Date
    Jul 2014
    Posts
    5
    Quote Originally Posted by benmartin101 View Post
    did you try this?

    Code:
    javascript:void(location.href='http://www.urlvoid.com/scan/'+encodeURI(window.location.host.replace("www.","")))
    just tried the code you suggested & it works perfectly , thank you very much sir , i really appreciate your help

Thread Information

Users Browsing this Thread

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

Tags for this Thread

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