Menu DaniWeb
Log In Sign Up
  • Read
  • Contribute
  • Meet
  1. Home
  2. Programming Forum
  3. Web Development Forum
  4. Code Snippet Repository
  5. Reusable Code Snippet

page links destroy

12 Years Ago Updated 12 Years Ago Troy III 0 Tallied Votes 185 Views Share

With this Spartan, we can destructively disable all the links on the page.
(Or whatever link collection we feed the Fn.arg.)

javascript seo
function destroyLinks(a){
        while( a[0] ){ a[0].outerHTML = a[0].innerHTML };
        }

usage:

    destroyLinks( document.links );
About the Author
Member Avatar for Troy III
Troy III 272 Posting Pro
Member Avatar for stbuchok
stbuchok
12 Years Ago

Is it really safe to modify an array while looping through that array? Isn't there a chance that can turn into an infinite loop? If no, then nice, otherwise I prefer a for loop (personal choice).

Member Avatar for Troy III
Troy III 272 Posting Pro
12 Years Ago

Perfectly safe.
A DOM Collection, is not an Array.
Inerently -perfectly faster!

Edited 12 Years Ago by Troy III
Member Avatar for Troy3
Troy3
12 Years Ago

On behalf of Troy III:
"Have I been silently banned my Queen -
And why did my code-snip, end up in a regular thread?"

Reply to this topic
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.

Sign Up — It's Free!
Related Topics
  • Member Avatar Web App State Management 1
  • Member Avatar Send Ajax request through link 5
  • Member Avatar error in displaying fetched data from db 1
  • Member Avatar Javascript not working as planned 1
  • Member Avatar Multiple routing help. 0
  • Member Avatar JavaScript and British Summer Time 6
  • Member Avatar Dynamic dropdown list 2
  • Member Avatar JavaScript Sleep 21
  • Member Avatar Small JavaScript Error 3
  • Member Avatar Javascript search string in array not working? 5
  • Member Avatar send a function in a JSON through java 2
  • Member Avatar Disable right click and view page source option 5
  • Member Avatar Data Not Updated Despite Positive Return Value From ExecuteNonQuery 3
  • Member Avatar Disable zoom in javascript 2
  • Member Avatar Pop up form in same window 2
  • Member Avatar javascript function to display message 1
  • Member Avatar help with using date/time 3
  • Member Avatar javascript in html - declare a variable? 24
  • Member Avatar disable right click and disable save as using javascript. 2
  • Member Avatar javascript css change stops after click 6
Not what you need?

Reach out to all the awesome people in our web development community by starting your own topic. We equally welcome both specific questions as well as open-ended discussions.

Start New Topic
Topics Feed
Reply to this Topic
Edit Preview

Share Post

Insert Code Block

  • Forums
  • Forum Index
  • Hardware/Software
    • Recommended Topics
  • Programming
    • Recommended Topics
  • Digital Media
    • Recommended Topics
  • Community Center
    • Recommended Topics
  • Latest Content
  • Newest Topics
  • Latest Topics
  • Latest Posts
  • Latest Comments
  • Top Tags
  • Topics Feed
  • Social
  • Top Members
  • Meet People
  • Community Functions
  • DaniWeb Premium
  • Newsletter Archive
  • Markdown Syntax
  • Community Rules
  • Developer APIs
  • Connect API
  • Forum API Docs
  • Tools
  • SEO Backlink Checker
  • Legal
  • Terms of Service
  • Privacy Policy
  • FAQ
  • About Us
  • Advertise
  • Contact Us
© 2025 DaniWeb® LLC