/    Sign up×
Community /Pin to ProfileBookmark

string search script that isn’t IE 9 compatible.

Hi… As a beginner i was very pleased with myself for figuring out how to convert an xml file to a string, using a couple tutorials and a little creativity The script pulls the first instance of an image’s url from the cdata section, and changes an image on my page…

then I tried it in IE 9. Damn. What should be done to the script below to make it function in internet Explorer 8 or 9?

(I also found that on my droid I got an xml error)

[CODE]<script>

$.ajax({
url: ‘http://www.website.com/folder/rss.xml’,
type: ‘GET’,
dataType: ‘text’,
timeout: 1000,
error: function(){
alert(‘Error loading XML document’);
},

success: function(xml){

var mySplitResult = xml.split(“img src=”);
var test = xml.search(“img src=”)+9;
var test2 = xml.search(“.jpg”)+4;

var cutout = xml.slice(test,test2);

document.image1.src=cutout;

}
});

</script>
<img src=”/storage/images/placeholder_mug.gif” id=”image1″ onload=”” />[/CODE]

to post a comment
JavaScript

0Be the first to comment 😎

×

Success!

Help @turpentyne spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.28,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...