Question

I have seen this answered several ways here in Stack Overflow, but after attempting the solutions nothing is working for my button. Here is the code I am using:

<center>
<div onclick="parent.location='http://google.com'" data-mce-onclick=""><button class="button"><font size=”6”>Visit Google</font></button></div>
</center>

The use of parent.location causes google to load in the current window. I have attempted open.window open.window.href adding ,’_blank’ and several other adjustments, but for whatever reason it still loads in the same window, or I lose the ability to link at all. What is the simplest way to adjust this code?

Was it helpful?

Solution

parent.location references the same window. And I don't know where you got the ideas for the other things you tried, but window.open seems to be what you're looking for:

<div onclick="window.open('http://google.com')" data-mce-onclick="">
  <button class="button"><font size=”6”>Visit Google</font></button>
</div>

It's worth noting also that you're using very old and deprecated tags. center and font should be replaced with CSS styling.

OTHER TIPS

You can use window.open documented here http://www.w3schools.com/jsref/met_win_open.asp

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top