/    Sign up×
Community /Pin to ProfileBookmark

Javascript Crashing IE 9?

Hi Guys,

Not sure if anyone can help but I’ve got a small piece of code that changes a piece of text its a URL and it first says “New Product” then “Product Name” this works in all browsers at current but IE crashes and says the page took to long to load.

Anyone got any tips or advice on how I can make this work in IE?

[code=html]<script type=”text/javascript”>

this.randomtip = function(){

var pause = 2000; // define the pause for each tip (in milliseconds) Feel free to make the pause longer so users can have time to read the tips 🙂
var length = $(“#tips li”).length;
var temp = -1;

this.getRan = function(){
// get the random number
var ran = Math.floor(Math.random()*length) + 1;
return ran;
};
this.show = function(){
var ran = getRan();
// to avoid repeating tips we need to check
while (ran == temp){
ran = getRan();
};
temp = ran;
$(“#tips li”).hide();
$(“#tips li:nth-child(” + ran + “)”).fadeIn(“fast”);
};
// initiate the script and also set an interval
show(); setInterval(show,pause);

};

$(document).ready(function(){
randomtip();
});
</script>[/code]

[code=html]<style>

#tips, #tips li{
margin:0;
padding:0;
list-style:none;
}
#tips{
width:250px;
font-size:16px;
line-height:120%;
}
#tips li{
display:none; /* hide the items at first only to display one with javascript */
}

</style>[/code]

[code=html] <ul id=”tips”>
<li><a href=”#”>New Product</a></li>
<li><a href=”#”>Product Name</a></li>
</ul>[/code]

Cheers In advance.

to post a comment
JavaScript

0Be the first to comment 😎

×

Success!

Help @ironfenix 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,
)...