It appears you have not yet registered with DEVPPL. To register please click here... (it's fast, easy and free!)

Forum

Log In Sponsors
Board index Programming CSS Forum

how to get specific string

how to get specific string

Postby liicis on Wed Jan 06, 2010 7:31 pm

Hi,
I have one issue:
to finish one of my functions I need access to specific string from html file, but I can't figure out how to do that.
For example I have html:
<li class="zumzum3" style="background-image: url(http://duu.lv/test2/images/stories/foto ... unde_1.jpg); background-repeat: no-repeat;" title="Dāvis Spunde"><img src="/test2/images/stories/fotografi/davis_spunde/Davis_Spunde_1.jpg" alt="Dāvis Spunde" border="0"></li>
And at the end I need to get result:
str="http://duu.lv/test2/images/stories/fotografi/davis_spunde/Davis_Spunde_1.jpg";
How can I cut that string that follow "li class= "zumzum3" style="background-image: url", and contains image url?
I realy don't know.
Thanks in advance.
liicis
 
Posts: 9
Joined: Thu Dec 17, 2009 12:49 pm

Re: how to get specific string

Postby liicis on Wed Jan 06, 2010 10:14 pm

OK, I did it by myself:
window.onload=gethtml;
function gethtml() {
var str = document.body.innerHTML;
str.toString();
var meklejam = str.search("zumzum3");
if(meklejam != -1){
var zz = str.search("zumzum3");
//alert(zz);
var nog = (str.substr(zz+38,200));
//alert(nog);
var nog1 = nog.search(';');
//alert(nog1);
var nog2 =(nog.substring(0,nog1-1));
//alert(nog2);
var str2 = '<img src="'+nog2+'" border="0">';
//alert(str2);
var str1 = 'Vieta_bildei';
var str3 = str.replace(str1,str2);
//alert(str3);
//document.body.innerHTML = str3;

}
liicis
 
Posts: 9
Joined: Thu Dec 17, 2009 12:49 pm


Who is online

Users browsing this forum: No registered users and 1 guest