www.webdeveloper.com
Results 1 to 4 of 4

Thread: can javascript remove or hide text from a page??

  1. #1
    Join Date
    Mar 2010
    Posts
    281

    can javascript remove or hide text from a page??

    i have a crap CMS to deal with (read Volusion Shopping CArt!) and am trying to remove the breadcrumb trail from some page. the page is full of tables nested within tables within tables etc. there are almost no classes or id's assigned to any of them... anyway...(venting)..

    i would like to remove the following code from the page

    &gt; <a href="http://nvpvr.anwfj.servertrust.com/Co_name_here/1817.htm" title="Floyd Beer Cheese">Company Name HEre</a>

    can Javascript search and replace text?,

    big thanks on this

  2. #2
    Join Date
    Apr 2006
    Posts
    66
    No.

    I presently recommend Volusions as a shopping cart.

    Just got tired of fighting the hackers with OsCommerce.

    This is propritory code which they will not grant assess to base.

    However, you have several pages of "switches" to change preferances.

    Additionally, Volusions "help" is par none. Ask them and they will provide a solution.

  3. #3
    Join Date
    Mar 2009
    Posts
    430
    If you need to replace text within an element you can do this:

    In your case the first arg would 'Company Name HEre' , followed by its replacement, followed by 'a'

    Code:
    function replace(oldTxt, newTxt, tag){
        var i, len, link = document.getElementsByTagName(tag);
        len = link.length;
        for(i = 0; i < len; i++){
    	if(link[i].innerHTML === oldTxt){
    	    link[i].innerHTML = newTxt;
    	    break;
    	}
        }
    }
    If you want to completely remove the element you can do this:

    Code:
    function remove(text, tag){
        var i, len, link = document.getElementsByTagName(tag);
        len = link.length;
        for(i = 0; i < len; i++){
    	if(link[i].innerHTML === text){
    	    link[i].parentNode.removeChild(link[i]);
    	    break;
    	}
        }
    }

    As long as you can identify the element you can change the text it contains.
    Last edited by Tcobb; 11-30-2012 at 12:23 PM.

  4. #4
    Join Date
    Apr 2006
    Posts
    66
    TCobb is correct, if Volusions would be willing to let you upload a javascript to thier server and share source code source code to identify ids.

Thread Information

Users Browsing this Thread

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

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