-1

I am creating a New Tab extension for Chrome, and, as part of it, need to change the z-index 3 seconds after page load. I have tried JavaScript, CSS and HTML, but cannot find the right code.

I am also very new to programming, and so any code posted would be a great assistance.

RealityDysfunction
  • 2,609
  • 3
  • 26
  • 53

2 Answers2

1

I'm not sure how extensions to Chrome work, but if injecting JavaScript is an option then it's literally a matter of waiting until the document is loaded (Examples here: Javascript that executes after page load )

Then waiting some time (Examples here: Put a Delay in Javascript)

Then simply setting the z-index of the element you want to edit.

document.getElementById(id).style.zIndex=newIndex;

However if what you're trying to do is some sort of animation, there are far more effective ways to achieve that.

Community
  • 1
  • 1
DBS
  • 9,110
  • 4
  • 35
  • 53
1

Pure JS

setTimeout(function(){
  document.getElementById("elementID").style.zIndex="1"
}, 3000);

or jQuery solution

setTimeout(function(){
  $('#elementID').css({ zIndex: '1' });
}, 3000);

*Note: You must include jQuery Library if you decide to use jQuery solution.

Milan and Friends
  • 5,560
  • 1
  • 20
  • 28