Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New to the CF scene
    Join Date
    Dec 2009
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Searching within code...

    I'm looking to find a way to search through javascript in the current document and save certain lines into an array. If the code had been in a div, I could easily use something like document.getElementById("Something".value but in this case, the code is in the header and I'm not positive how to read the information.

    Any suggestions would be a great help.

  • #2
    Supreme Master coder! Philip M's Avatar
    Join Date
    Jun 2002
    Location
    London, England
    Posts
    17,910
    Thanks
    203
    Thanked 2,531 Times in 2,509 Posts
    Could you please give a clearer explanation of what you are trying to achieve, and why you want to do this?

    You can capture the entire HTML page source thus:-

    Code:
    <script type="text/javascript" >
    
    window.onload=function(){
    var str = document.getElementsByTagName('html')[0].innerHTML;
    alert (str);
    }
    
    </script>
    "Success is the ability to go from one failure to another with no loss of enthusiasm."
    Sir Winston Churchill, British politician (1874 - 1965)


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •