1

I need a little guidance. I am trying to delay the execution of these two functions until after the page is fully loaded or timebomb them to happen after 5000 ms.

I am using the latest jquery 1.6

Thank you in advance for your help and code snippits :)

$("a.siteNavLink").each(function() {
   var _href = $(this).attr("href"); 
   $(this).attr("href", _href + '?p=client');
});
$("a.footernav").each(function() {
   var _href = $(this).attr("href"); 
   $(this).attr("href", _href + '?p=client');
});

2 Answers 2

3

You can use

$(window).load(function(){ your code here }) // page has loaded including images 

or

$(document).ready(function(){ your code here }) // dom has loaded 
Sign up to request clarification or add additional context in comments.

Comments

2
$(document).ready(function() {
  // Your code here
});

That will make your code run only when the document is fully loaded

jQuery ready() documentation

1 Comment

so along these lines $(document).ready(function() { $("a.footernav").each(function() { var _href = $(this).attr("href"); $(this).attr("href", _href + '?p=client'); }); });

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.