May I know what's the problem with this code? I'd try to run it in my index.php in on of joomla module, but the site output is just white.
echo ' < a style="cursor: pointer;" >onclick="location.href='http://example.com/index.php' ">Admin < /a>';
I'd like to make the link for the example.com/index.php not appear / disabled when I put the cursor on the link. I'd try run the code above at the Try It! on w3school.com and it works perfectly, but if I put the code in my file in joomla module, it's not work!
Hope somebody could help me.. thanks in advance
You have an error in your code
echo ' < a style="cursor: pointer;" >onclick="location.href='http://example.com/index.php' ">Admin < /a>';
The Error
Parse error: syntax error, unexpected 'http' (T_STRING), expecting ',' or ';' in index.php on line 7
< a>
is not correct and should be <a>
also applies with the closing tag </a>
>
character near the style="cursor: pointer;"
window.location.href
instead of location.href
because you are trying to return the url of the current page.\"
The correct php code.
echo "<a style='cursor: pointer;' onclick='window.location.href=\"http://example.com/index.php\"'>Admin</a>";