Solved

disable shadowbox links in image map

Posted on 2013-05-26
5
982 Views
Last Modified: 2013-05-28
Hi
I have an image map implementing shadowbox and I would like to disable shadowbox for several of the links contained in the image map. How can I do this? Right now all the links inside the image map come up inside the shadow box, since shadowbox is relating to all the area tags.

<script type="text/javascript">
         Shadowbox.init();
          window.onload = function() {         Shadowbox.setup(document.getElementById("map").getElementsByTagName("area"));
      handleOversize: "resize"
}
</script>
0
Comment
Question by:avir
  • 3
  • 2
5 Comments
 
LVL 25

Accepted Solution

by:
clockwatcher earned 500 total points
ID: 39198474
You can pass an array to the Shadowbox.setup call in which the first element is a css selector and the second element is the parent item that you want it to grab the anchors from.  In other words,
<html>
	<head>
		<link rel="stylesheet" type="text/css" href="http://www.shadowbox-js.com/build/shadowbox.css"> 
		<script type="text/javascript" src="http://www.shadowbox-js.com/build/shadowbox.js"> </script>
		<script language="javascript"> Shadowbox.init(); </script>
		<script language="javascript">
			window.onload = function() {
				Shadowbox.setup(['.shadowbox', document.getElementById('six_sided_map')]);
			}
		</script>

	</head>
	<body>

		<img id="six_sided" src="http://lightwiki.stuartmcbride.com/mediawiki/images/4/46/Die_pip_template.png" usemap="#six_sided_map" />
		<map name="six_sided_map" id="six_sided_map">
			<area class="shadowbox" shape="rect" coords="100,0,200,100" href="http://www.aaronbushell.com/wp-content/uploads/2013/03/one-finger.jpg" />
			<area shape="rect" coords="100,100,200,200" href="http://school.discoveryeducation.com/clipart/images/fun-2.gif" />
			<area class="shadowbox" shape="rect" coords="200,100,300,200" href="http://www.clker.com/cliparts/U/J/0/x/g/L/red-rounded-with-number-3-md.png" />
			<area shape="rect" coords="0,100,100,200" href="http://quanticolive.com/wp-content/uploads/2013/03/Four-leaf-clover.gif" />
	    	</map>
	</body>
</html>

Open in new window


The one and three are shadowboxed because they have the shadowbox class (which was passed in the setup call).  Two and four aren't shadowboxed.  I was too lazy to do anything with five or six.
0
 

Author Closing Comment

by:avir
ID: 39198522
Works greats. Thanks for your help.
0
 

Author Comment

by:avir
ID: 39198677
Hi clockwatcher
Actually this has created another problem. Now my height definitions (rel="shadowbox; height=300") for some of the links are not recognized since they are based on the rel attribute and all the iframe windows default to 100%  height.

Any way to get around this?
0
 
LVL 25

Expert Comment

by:clockwatcher
ID: 39199337
Can you post an example?  The following appears to work for me:
 <html>
	<head>
		<link rel="stylesheet" type="text/css" href="http://www.shadowbox-js.com/build/shadowbox.css"> 
		<script type="text/javascript" src="http://www.shadowbox-js.com/build/shadowbox.js"> </script>
		<script language="javascript"> Shadowbox.init(); </script>
		<script language="javascript">
			window.onload = function() {
				Shadowbox.setup(['.shadowbox', document.getElementById('six_sided_map')]);
			}
		</script>

	</head>
	<body>
		<a href="./test1.html" rel="shadowbox;width=100;height=100" title="Test 1">Test 1</a>
		<br/>


		<img id="six_sided" src="http://lightwiki.stuartmcbride.com/mediawiki/images/4/46/Die_pip_template.png" usemap="#six_sided_map" />
		<map name="six_sided_map" id="six_sided_map">
			<area class="shadowbox" shape="rect" coords="100,0,200,100" href="http://www.aaronbushell.com/wp-content/uploads/2013/03/one-finger.jpg" />
			<area shape="rect" coords="100,100,200,200" href="http://school.discoveryeducation.com/clipart/images/fun-2.gif" />
			<area class="shadowbox" shape="rect" coords="200,100,300,200" href="http://www.clker.com/cliparts/U/J/0/x/g/L/red-rounded-with-number-3-md.png" />
			<area shape="rect" coords="0,100,100,200" href="http://quanticolive.com/wp-content/uploads/2013/03/Four-leaf-clover.gif" />
	    	</map>
                <br />
		<a href="./test1.html" rel="shadowbox;height=300" title="Test 2">Test 2</a>
	</body>
</html>

Open in new window

0
 

Author Comment

by:avir
ID: 39200427
Sorry, I was mistaken. I can still use the rel attribute to determine the height of the iframe.
Thanks,
0

Featured Post

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

This article discusses four methods for overlaying images in a container on a web page
Is your Office 365 signature not working the way you want it to? Are signature updates taking up too much of your time? Let's run through the most common problems that an IT administrator can encounter when dealing with Office 365 email signatures.
In this tutorial viewers will learn how add a scalable full-width header using CSS3. Create a new HTML document with an internal stylesheet. Set a tiled background.:  Create a new div and name it Header. Position it with position:absolute at the top…
The viewer will receive an overview of the basics of CSS showing inline styles. In the head tags set up your style tags: (CODE) Reference the nav tag and set your properties.: (CODE) Set the reference for the UL element and styles for it to ensu…

776 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question