Javascript to modify content of a rendered page.

Discussion in 'OT Technology' started by Phil Blunts, Jan 19, 2006.

  1. Phil Blunts

    Phil Blunts Guest

    I'm currently doing some sharepoint development. It sucks. Here's what I need help with.

    Say a page is rendered and it has a link in it. I want to be able to remove the link from the HTML once the page is rendered by using javascript.

    I can do all the backend stuff to figure out whether or not the page needs the link removed based on the user's permissions. Basically I'll just programatically add an OnLoad event to the body tag. I just need help figuring out how to write the javascript to search the HTML for the tag I give it then remove it. I guess I would get it by ElementID or maybe innerhtml because I'm not certain that they will all have an elementID.

    Help, please.
     
  2. MrMan

    MrMan New Member

    Joined:
    Jul 13, 2004
    Messages:
    308
    Likes Received:
    0
    My javascript may be a little off.

    You're right, the links should have an ID.
    <a href="home.html" id="link123">Home</a>

    and then you have your
    <body onload="linkBeGone();">

    somewhere in the header
    <head>
    <script language="Javascript" type="text/javascript">
    <!--
    function linkBeGone()
    {
    document.getElementByID(link123).style.visibility = 'hidden';
    }
    -->
    </head>


    Javascript will see all links with element id link123 as an object. Therefore, it "does the searching for you". But this assumes that all links have an element id.
     
  3. Phil Blunts

    Phil Blunts Guest

    Thanks, I figured it out earlier.

    Now I just have to figure out how to programmaticaly determine when to fire and when not to fire that function based off of the user's sharepoint permissions.

    Ghetto sharepoint development FTW!
     

Share This Page