Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

unlink a hyperlink

Posted on 2004-09-10
8
Medium Priority
?
268 Views
Last Modified: 2010-05-18
heres all the code involved though you probably only need to look at the top function.  i'm trying to unlink a hyperlink.  the pesky href is still staying around though which makes it still look like a hyperlink.  i've tried setting it to "" and to null.  any ideas??

function WP_Unlink(wpName) {
      HideIfOpen(); // hides menu if open
      Backup();
      var link= WP_GetClosest(wpName,"a");      
      if(!link) {
            return;
      } // end if      
      link.href= null;      
      link.style.fontFamily= currentFont;
      link.style.fontSize= WP_TranslateFontSize(currentFontSize);
      editor.focus();    
} // end function

function WP_GetClosest(wpName,tagName) {
      var editor = WP_GetIFrame(wpName);
      var ancestors = WP_GetAllAncestors(wpName);
      var ret = null;
      tagName = ("" + tagName).toLowerCase();
      for (var i in ancestors) {
            var el = ancestors[i];
            if (el.tagName.toLowerCase() == tagName) {
                  ret = el;
                  break;
            }
      }
      return ret;
}
function WP_GetAllAncestors(wpName) {
      editor = WP_GetIFrame(wpName);
      var p = WP_GetParentElement(wpName);
      var a = [];
      while (p && (p.nodeType == 1) && (p.tagName.toLowerCase() != 'body')) {
            a.push(p);
            p = p.parentNode;
      }
      a.push(editor.document.body);
      return a;
}
0
Comment
Question by:das165227
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
8 Comments
 
LVL 36

Expert Comment

by:Zyloch
ID: 12030893
Hi

You might want to try setting link.href="http://www.google.com/" or "#" just to check if it works. Do some trial and erroring. See if it's one of your other functions. We can probably look through it, but it's so much faster when you narrow it down.

Regards,
Zyloch
0
 
LVL 36

Expert Comment

by:Zyloch
ID: 12030901
You might also want to try this:

Change link.href= null; to
link.outerHTML="";

Regards
0
 

Author Comment

by:das165227
ID: 12031023
setting it to inner or outer html deletes the whole thing.  i'd like to leave the text but if nothing else i can delete the whole thing and put text back in though i'd like the shorter way if there is one
0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 

Author Comment

by:das165227
ID: 12031029
that probably didn't make much sense.  setting innerHTML or outerHTML= "" made the whole thing disappear but that gives me an idea.
0
 
LVL 36

Accepted Solution

by:
Zyloch earned 1400 total points
ID: 12031066
I dunno. Store innerHTML in a temp var then write it again?
0
 
LVL 15

Expert Comment

by:VincentPuglia
ID: 12038693
<a href="http://members.aol.com/grassblad" onmouseover='this.outerHTML=this.innerHTML'>GrassBlade</a>

Vinny
0
 
LVL 1

Expert Comment

by:pfiev
ID: 12039039
To remove a link is not to remove the HREF property.
This is an example showing how to replace a link with its content:

<body>
<a id="te" href="ok">hihi </a>
<script>
function unlinkA(el)
{
      document.body.replaceChild(document.createTextNode(el.innerHTML), el);
}
unlinkA(document.getElementById('te'));
</script>
</body>

To remove all links in the document, just do a loop with document.getElementsByTagName('A')
0
 

Author Comment

by:das165227
ID: 12044767
zyloch thats basically what i ended up doing.  i did this before i even read that answer from you.  your ealier post about inner and outer html gave me an idea so i did:

function WP_Unlink(wpName) {
      HideIfOpen(); // hides menu if open
      Backup();
      var link= WP_GetClosest(wpName,"a");      
      if(!link) {
            return;
      } // end if      
      link.outerHTML= "<span style= 'font-family:" + currentFont + ";font-size:" + WP_TranslateFontSize(currentFontSize) + "';>" + link.outerText + "</span>";            
      editor.focus();    
} // end function
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Browsers only know CSS so your awesome SASS code needs to be translated into normal CSS. Here I'll try to explain what you should aim for in order to take full advantage of SASS.
Originally, this post was published on Monitis Blog, you can check it here . In business circles, we sometimes hear that today is the “age of the customer.” And so it is. Thanks to the enormous advances over the past few years in consumer techno…
Viewers will learn about the regular for loop in Java and how to use it. Definition: Break the for loop down into 3 parts: Syntax when using for loops: Example using a for loop:
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.

670 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question