chopper
04-25-2008, 11:34 PM
Hi
I have the following code that puts a web address (after the "-") into a new window. What I would like is to adapt the code to say, if after the dot (.) in the web address the extension is html or htm, then display in a window (as it is now) BUT if it is a .mp3 for example www.web.com/sound.mp3 then open in iFrame (that is on site), I understand it must be in some way similar to the code Ive already done for the after "-" circumstance but just cant get it.
Im really sorry but cant add web as its on an internal server.
Hope Ive been a little clearer.
Heres the code, its part of a sndReq() Function, when user presses button
var Message = 'Initial Value'; // Declare var
if ( xmlDocumentElement.firstChild == null )
{
Message = "Can you re-phrase that question please";
}else{
Message = xmlDocumentElement.firstChild.data;
}
//////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)
{
window.open(website,'','scrollbar=no,height=500,width=400');
//alert(Message);
}
I have the following code that puts a web address (after the "-") into a new window. What I would like is to adapt the code to say, if after the dot (.) in the web address the extension is html or htm, then display in a window (as it is now) BUT if it is a .mp3 for example www.web.com/sound.mp3 then open in iFrame (that is on site), I understand it must be in some way similar to the code Ive already done for the after "-" circumstance but just cant get it.
Im really sorry but cant add web as its on an internal server.
Hope Ive been a little clearer.
Heres the code, its part of a sndReq() Function, when user presses button
var Message = 'Initial Value'; // Declare var
if ( xmlDocumentElement.firstChild == null )
{
Message = "Can you re-phrase that question please";
}else{
Message = xmlDocumentElement.firstChild.data;
}
//////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)
{
window.open(website,'','scrollbar=no,height=500,width=400');
//alert(Message);
}