Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1010
  • Last Modified:

disable shadowbox links in image map

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
avir
Asked:
avir
  • 3
  • 2
1 Solution
 
clockwatcherCommented:
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
 
avirAuthor Commented:
Works greats. Thanks for your help.
0
 
avirAuthor Commented:
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
 
clockwatcherCommented:
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
 
avirAuthor Commented:
Sorry, I was mistaken. I can still use the rel attribute to determine the height of the iframe.
Thanks,
0

Featured Post

[Webinar] Cloud and Mobile-First Strategy

Maybe you’ve fully adopted the cloud since the beginning. Or maybe you started with on-prem resources but are pursuing a “cloud and mobile first” strategy. Getting to that end state has its challenges. Discover how to build out a 100% cloud and mobile IT strategy in this webinar.

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now