CodeWithPride
CodeWithPride

Reputation: 123

HTML open new window on image onclick

I have a single image in my web page, this image is basically an architecture diagram and I need to open a new window every time someone clicks this image with different content in the new opened window based on which component of the architecture diagram has been clicked by the user. How can I best achieve this feature? Please help as I am new to this.

Upvotes: 0

Views: 5661

Answers (4)

Nick
Nick

Reputation: 2325

Perhaps use an image map and define area tags within it. This is the best way I can think of to support an image with multiple regions within it.

Upvotes: 1

Peter
Peter

Reputation: 14108

Make an image map. You can do this by hand or via online tools (just Google around, this is the first one I found). For your links use target="_blank" and it will open a new window/tab.

Upvotes: 1

Simonas B.
Simonas B.

Reputation: 191

I'd suggest using map tag, i think it's easier than JavaScript

http://www.w3schools.com/tags/tag_map.asp

Upvotes: 0

Richard
Richard

Reputation: 22016

This will do it

<a href="http://www.somesite.com" target="_blank">Link text </a>

If you are using an image map for the links, just set the target to be _blank for each.

On a different note, do you have to open in a new window? It's just this will break the natural navigation of a browser and render the back button useless. Ending up with many new open tabs is more confusing and can be a bad user experience. Just a thought.

Upvotes: 2

Related Questions