PDA

View Full Version : indexof help EDITED



chopper
04-25-2008, 09:28 AM
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);
}

jscheuer1
04-25-2008, 06:57 PM
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:


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.

chopper
04-25-2008, 11:25 PM
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!

chopper
04-25-2008, 11:36 PM
http://dynamicdrive.com/forums/showthread.php?t=31893