How to make this code open a new window:
<! ---
<button class="button" onclick="window.location.href='https://www.upwork.com/freelancers/michaelkiger';">Contact Owner</button>
--->
How to make this code open a new window:
<! ---
<button class="button" onclick="window.location.href='https://www.upwork.com/freelancers/michaelkiger';">Contact Owner</button>
--->
Here is how to post code in the forum
When you enter a code block into a forum post, please precede it with a separate line of three backticks and follow it with a separate line of three backticks to make it easier to read.
You can also use the āpreformatted textā tool in the editor ( </>
) to add backticks around text.
See this post to find the backtick on your keyboard.
Note: Backticks (`) are not single quotes (ā).
You must use <!--
-->
just for HTML comments
You donāt use HTML comment tags correctly. You must write <!--
-->
instead of
<! ---
--->
If clicking something navigates user from the page it should be an anchor tag (<a>
). Buttons are for actions on the page.
Yes, usually it would be in an anchor tag. This application of the button class with the url does work. It goes to the url āonclickā but it does not open in a new window. I tried using target=_blank to no avail⦠this is part of a css style sheet. I am hoping to avoid re-writing half the style sheet just to make it open in a new window āonclickā
Because target=__blank
is for anchor tag.
For window itās window.open(url)
.
Nevertheless, it still should be an anchor tag.
Ty, however I did try window.open⦠maybe I did not have the syntax correct for the entire line of code⦠will try again and let you know.
This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.