Results 1 to 4 of 4

Thread: indexof help EDITED

  1. #1
    Join Date
    Apr 2008
    Posts
    9
    Thanks
    3
    Thanked 0 Times in 0 Posts

    Default indexof help EDITED

    I have text that is displayed to a user on a website, the following javascript code then tells the system to take whatever is after two spaces in the text after "-" and display in an iframe, in this case it would be a http web address.

    Once the address has been placed into an iframe I would like all text after the "-" to no longer be displayed to the end user, using some king of 'clear' function maybe?!


    //////Website Parsing
    var the_url = Message; //prompt("What's the URL?","");

    //assign the chararter position of the symbol to 'dash'
    var dash = the_url.indexOf("-");

    //alert(dash);

    //get character position 2 characters after the dash variable
    var domain_start = dash + 2;

    ///get everything after the character poistion domain_start and set to variable website
    var website = the_url.substring(domain_start, the_url.length);




    //if dash is equal to or more than 19 charcater position
    //then put the website variable in the iframe.
    if (dash >= 19)
    {

    document.getElementById("iframe").src = website;

    //alert(Message);
    }
    Last edited by chopper; 04-25-2008 at 10:14 AM. Reason: Better description of whats needed

  2. #2
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    Your example code will not do anything (Message is undefined). Perhaps you left out some of it.

    If you just want to reset the variable Message to whatever, all you need to do is after you have loaded up the iframe is:

    Code:
    Message="The URL is -  ";
    or to whatever you want it to be. To change something that's visible on the page, you would need to change either its value (if it is a textarea or input), or its textNode(s)'s node value(s) or its innerHTML property if it is another sort of element, like a span or a div.

    If you want more help:

    Please post a link to the page on your site that contains the problematic code so we can check it out.
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  3. The Following User Says Thank You to jscheuer1 For This Useful Post:

    chopper (04-25-2008)

  4. #3
    Join Date
    Apr 2008
    Posts
    9
    Thanks
    3
    Thanked 0 Times in 0 Posts

    Default

    hi, thanks for your reply, Ive since discovered what I wanted I no longer require.

    I have another problem with same code that I will post, I will try and post better this time, sorry!

  5. #4
    Join Date
    Apr 2008
    Posts
    9
    Thanks
    3
    Thanked 0 Times in 0 Posts

Bookmarks

Posting Permissions

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