change the title

Discussion in 'JavaScript' started by cucuru, Feb 24, 2010.

  1. #1
    hello! In my own code, when I use a link, it opens a external site in a new tab, and I would like to change the title of this external site. it is:

    
    <a href ='http://www.google.es'  target='_blank'> Link </a>
    
    PHP:
    Well, does it exist any javascript function that does what I want?

    Thanks!
     
    cucuru, Feb 24, 2010 IP
  2. s_ruben

    s_ruben Active Member

    Messages:
    735
    Likes Received:
    26
    Best Answers:
    1
    Trophy Points:
    78
    #2
    You have to edit the external site code and change the title of it. I think there is no code to change it from other code if you have no permission to edit just the file.
     
    s_ruben, Feb 24, 2010 IP
  3. dimitar christoff

    dimitar christoff Active Member

    Messages:
    882
    Likes Received:
    62
    Best Answers:
    0
    Trophy Points:
    90
    #3
    you can change it by setting a title attribute

    like
    
    <a id="mylink" href ='http://www.google.es'  target='_blank'> Link </a>
    
    ...
    
    document.getElementById("mylink").setAttribute("title", "click here to visit google.es!");
    
    Code (javascript):
    if you don't have access to the source (i.e. external js included), then you can consider traversing the dom from the link's first parent you can easily reference, for example, for:

    <div id="menu"> <a href=""> some link </a> <a href="http://google.es">google</a></div> -> document.getElementById("menu").getElementsByTagName("a")[1] will target the google link directly.

    but it won't hold any SEO value so better do as rubben has suggested.
     
    dimitar christoff, Feb 25, 2010 IP