SCcode SCcode - 8 months ago 43
PHP Question

Can you auto load an href without having to click something?

I want to activate this href

<p><a class="button" href="#popup1">Click Me</a></p>

without having to use the button. So for example,

if ($info == "this") {
//go to href=#popup1 here

I tried doing this,

if ($info == "this") {
print "<meta http-equiv='refresh' content='0; url=#popup1' />";

but it just gets stuck in a loop.


By keeping some id to your a tag, you can achieve this by .click() function

<p><a class="button" id="popup1" href="#popup1">Click Me</a></p>

if (true /*your logic*/) {
   echo '<script>document.getElementById("popup1").click()</script>';