How to open lightbox on page load? - javascript

I would like to use this nice gallery for bootstrap when I click onto a specific location on an image : http://ashleydw.github.io/lightbox/
It works really fine but now on another page I'd like to open the gallery at the page load, without a click. Is it possible ?
Here my code :
<area target="" alt="" title="" href="https://www.youtube.com/embed/....&rel=0" data-toggle="lightbox" data-gallery="hidden-images" coords="1,0,2,718,215,714,211,841,1190,841,1187,1" shape="poly">
Thanks for help !

OK so I have the answer here :
<area id="#open-youtube" target="" alt="" title="" href="https://www.youtube.com/embed/....&rel=0" data-toggle="lightbox" data-gallery="hidden-images" coords="1,0,2,718,215,714,211,841,1190,841,1187,1" shape="poly">
<script type="text/javascript">
$('#open-youtube').ready(function (e) {
$('#open-youtube').ekkoLightbox();
});
</script>
I hope it will help somehone.

Related

Replace this.href with this.title

The below code works perfectly to reveal an image when a user mouses over an hotspot of an image map. The only problem? When clicked 'this.href' of course takes the user to the hotspot image itself. I'd like to reserve 'href' to send the users to the page of my choosing.
Is it possible to use "title" rather than 'href' to define the hotspot image? If so, please show details, I'm very new to javascript, thank you!
<script type="text/javascript">
function ShowPicC(sImage){document.housec.src = sImage}
</script>
<img border="0" src="main-image.png" width="640" height='640' usemap="#FPMap0">
<map name="FPMap0">
<area onmouseover='ShowPicC(this.href)' href='hotspot1.png' alt="thisalt" title="can-png-go-here.png" shape="circle" coords="400,400,20">
<area onmouseover="ShowPicC(this.href)" href="hotspot2.jpg" alt="youralt" title="can-png-go-here2.png" shape="circle" coords="420,420,20">
<area onmouseover="ShowPicC(this.href)" href="hotspot3.jpg" alt="differentalt" title="can-png-go-here3.png" shape="circle" coords="440,440,20">
<area onmouseover="ShowPicC(this.href)" href="hotspot4.jpg" alt="whateveralt" title="can-png-go-here4.png" shape="circle" coords="460,460,20">
</map>
<img name="housec" src="starter-hotspot-image.png" width="192" height="170">
Sure, although title isn't a valid property of area. Did you try it?
<area onmouseover="ShowPicC(this.title)" title="someotherimage.jpg" ...
You may be better off using a data attribute:
<area data-image="someotherimage.jpg" ...
https://developer.mozilla.org/en-US/docs/Web/Guide/HTML/Using_data_attributes

event.target/srcElement not working 100% in Chrome and Opera

I'm trying to get the target/srcElement of an HTML "area" element for an image map.
Here's what I have so far (pardon the data URI):
<map name="dpad">
<area id="dpad"shape="rect" alt="" title="" coords="1,14,12,24" onmousedown="move('l',false,event);" target="" />
<area shape="rect" alt="" title="" coords="15,2,24,12" onmousedown="move('u');" target="" />
<area shape="rect" alt="" title="" coords="27,15,38,24" onmousedown="move('r');" target="" />
<area shape="rect" alt="" title="" coords="15,27,25,38" onmousedown="move('d');" target=""/>
</map>
<img width="40"height="40"src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACgAAAAoCAYAAACM/rhtAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAgY0hSTQAAeiYAAICEAAD6AAAAgOgAAHUwAADqYAAAOpgAABdwnLpRPAAAABp0RVh0U29mdHdhcmUAUGFpbnQuTkVUIHYzLjUuMTAw9HKhAAADDElEQVRYR+2ZvYoiQRSFW1EMVkEzI2XfydQH2GwGDTfczFRYNNBBUDFQUFN9ATXQwEEDRQ3UB3ADQajpr7Gkp8f+k2G6F2bg0jVVt+qcrp9zb5cBxeVfMpmMnE6nX+fz+U8kEvkRCoUsR7hcLorq+0/1/R2NRv8ej8ezS0h37uFwOBEMBkupVErk83lRKBQsDR986UNfd2gPeAcCgYRqpUwmI+bzuTgcDjcbj8cC09fhgy996PsApLsukmA2mxWLxeJGhnKz2dTMWI+vpwRXq5XodDqi3W5rRpk6ZhKynhLc7XZiMBiIVqsler2eZpSpo81zgqPRSDQaDdHtdkW/39eMMnXsR08JTqdTUSqVRK1WE/V6/Z1RVy6XBT6eLTEzNJlMLA0fzwjqT6teWvRlT5f4myASnU6nI4SgqwA7ef5UfV+MQu1giV/UfvR1gpGAE9wUNYA/EyevSu/kCdDrAwRfeTGnOHCKxWLPipqNnAjmxEtAnVqxWBTr9fpd3L03i/jg63Rc/OACJ7gxg1pWQlBn0+sNDZNia2wDeL/f3wgSNWazmWaUJVl88DX253/GBsPYBhc4wU2Jx+NauqR/ewCIEIgwOme2v6jfbDZiOByKarWqCTZWqVS0UEebVV/GBgMs/UvRB05w+0CQIM/ghCrA7AhCjihCDJahjjJ1tNkRBAMsMGWCYUqQqSYTIdgTTwGxIshbM3N6cnqStG23W1OSjA0GWGCCLbX1wwyyH8jlSJckoB1B9hszIEkZn7ThYzaLkiD9wAQbDnD5/wjylsvl8lOXmMPidonh8GWHhI3/qYdEDsbmZx+Qz9md4nsyw+HgBDuRGTDAMpUZxDCXy5kKNQTviaxRqFlKKdT6ZbUSasY2E2o4aULt+1BHQPZ1suD7dMvdZ7uimH24O8gHvb1Z+CbodKn1Sywvi+yenn12omEIrUyZSJuk+eLDXWbFvr36gKDvL484vb6+fpPy4rsLTN9eAesv0ck47C7R8fnSS3R+hlDToCeV6Il0iE9DK8Pn6vtEX6d6K/3eAH0oKaUOiMCyAAAAAElFTkSuQmCC"usemap="#dpad"/>
So, for the left arrow on the dpad, I have a function to be called onmousedown, move(dir,hold,e).
Here is the function started:
function move(dir,hold,e){
var p=document.getElementById('test');
alert(e);
}
This is confusing the crap out of me as to why I'm getting "undefined" when clicking on the area. Could someone please explain in FULL detail as to how I can get the target?
Do I need to include 'event' as a parameter in my HTML code? Do I even NEED a parameter for it?
On another note, here's something that really confused me.
So, I can't get the target of that element, but this works just fine:
<div class="male1-d" id="test" data-sprite="male1" onclick="alert(event.target+' '+this.style.left+' '+this.style.top);"></div>
Done. Target obtained. Now why can't I do it in a function?
I forgot to mention that for Opera I meant mobile(?) version 9.50.
in some browsers,'event' is a attribute of window.But you need to include 'event' as a parameter in others.So your move function should be like below:
<html>
<body>
<button onmousedown='move(event)' id='btn' name='a button'>click</button>
</body>
<script>
function move(e){
var e=e||window.event;
var target=e.target||e.srcElement;
alert(target);
alert(target.id);
alert(target.name);
}
</script>
</html>
It seems , it is a problem in the click event.
They says , it is a bug in jquery. And has given details in
Jquery click event of a div in li element not fired in mobile Safari
It says two things:
Add cursor:pointer to the DIV class.
Add onclick="" to the element

Fancybox Imagemap Gallery

What I want is an image which after been clicked opens a gallery. I'm using FancyBox, and I want Thumbnail Helper(with image map)
It's like this: http://jsfiddle.net/ffZ7B/343/
When you click the left weel, It opens the gallery, but it dosn't show the thumbnails.
I tried this: http://jsfiddle.net/ffZ7B/344/
Does anyone knows how to do this?
Thank you!
The Thumbnail Helper is a totally NEW feature of fancybox v2.x and non-existing in previous versions. You are using fancybox v1.3.4 in your jsfiddle.
If you want to use the Thumbnail Helper, you have to upgrade to Fancybox v2.x, then use this code:
HTML :
<img src="images/imageMap.jpg" usemap="#map" />
<map name="map" id="map">
<area class="fancybox" href="images/01.jpg" data-fancybox-group="gallery" shape="rect" coords="46,38,201,154" title="01" />
<area class="fancybox" href="images/02.jpg" data-fancybox-group="gallery" shape="rect" coords="295,35,388,83" title="02" />
<area class="fancybox" href="images/03.jpg" data-fancybox-group="gallery" shape="rect" coords="27,166,134,293" title="03" />
</map>
JS :
$(document).ready(function() {
$("area.fancybox").fancybox({
helpers: {
thumbs : {
width : 50,
height : 50
}
}
}); // fancybox
}); // ready
NOTICE that we used the data-fancybox-group="gallery" attribute in order to set the gallery elements (rel won't work with the area tag as it used to work with v1.3.4.) You may need to set a HTML5 DOCTYPE though for validation purposes.
UPDATE : See working DEMO here - NOTE (Jan 15, 2013) this demo will fail because is using jQuery v1.9.0. Check THIS for further reference. You could reproduce a working demo with jQuery v1.8.3 though.

web page with java script not working in firefox

I am using a map on an image. Inside that map I got onmouseover effects for different areas. Also, I have a script that opens an image thumbnail when that area is clicked. This is the script I'm using: http://britobmarketing.com/thumbnailviewer.js
The problem is it's not working in firefox. Not the onmouseover effect, not the thumbnail script. It's simply not working.
Any recommendations?
I really want to stick with java script and not get into Jquery!
Thanks a lot!
Assuming that the page you are using this on is: http://britobmarketing.com/
Your problem seems to be with how you are defining your imagemap; not how the javascript is working
Your imagemap setup:
<map name="mainMap">
<a rel="thumbnail" href="images/contactUsPic.jpg">
<area onmouseout="document.pic1.src='images/mapPics.gif'" onmouseover="document.pic1.src='images/contactUs.gif'" title="Contact Us" shape="rect" coords="798,481,877,572">
</a>
<area target="_blank" href="http://www.facebook.com/britoBMarketing" title="Facebook" shape="rect" coords="884,298,956,357">
</map>
Playing around with Firebug's "inspect element", it seems that stripping out the target and title attributes seems to remove the problem.
Also your main <area/>s are wrapped with anchors (<a>) which is probably preventing them from working.
Try something like this:
<map name="mainMap">
<area coords="191,138,487,233" shape="rect" href="" onmouseover="alert('hello')">
</map>

JQuery using the click event handler. How do I keep all the elements from not show only have one element show one at time?

In jquery using the click event handler. How do I keep all the elements from not show but only have one element show one at time to what is related when I click on it?.
My example page: http://chrism.net46.net/final-ff-IX/summoners-paintings.html
Using a image map. I have ten "hot spots", each a monster painting and 10 divs with information about each painting. When I click a hot spot I just a lightbox with info about that page segment to open.
I have used jquery plugins like jquery tools with success, but I'd like to learn how without using a plugin.
Anyway here is a video example what I mean starting at 0:15 http://www.youtube.com/watch?v=7628mBPumM4 hope this is more clear.
Here http://jsfiddle.net/muThj/1/ without the image map, though. Using it to host the code review just in case the above link site goes down due to traffic.
<img src="wall-writings.jpg" alt="Eidolon mural paintings of Curbuncle, Madeen, Ramuh, Shiva, Ark, Ifrit, Leviathan, Phoenix, Fenrir, Atomos" usemap="#eidolonpaintings">
<map name="eidolonpaintings">
<area shape="poly" coords="287,230,301,244,319,251,329,252,340,252,347,252,338,246,336,237,344,233,344,229,345,225,356,227,362,229,376,230,385,235,393,242,396,250,403,254,408,248,414,239,419,231,424,224,429,222,433,233,432,248,428,263,422,272,422,279,410,286,396,288,388,291,385,293,390,296,393,305,396,316,400,318,407,320,414,325,416,332,420,343,415,352,414,360,408,369,401,374,405,387,409,399,407,409,408,412,402,414,368,365,357,374,358,390,359,403,354,409,343,415,337,416,323,370,294,362,268,327,264,274,287,230" >
<area shape="poly" coords="628,253,617,222,624,172,630,149,647,109,667,81,681,66,694,53,720,49,756,48,768,53,775,75,825,99,924,135,981,154,1019,169,912,266,795,312,747,372,670,335,628,253" >
<area shape="poly" coords="1018,196,1029,182,1040,174,1043,167,1043,153,1045,138,1059,132,1076,137,1079,159,1082,176,1090,189,1110,249,1127,269,1132,286,1127,303,1146,380,1150,400,1136,409,1095,417,1067,418,1046,415,1029,405,1009,409,988,405,974,399,967,391,977,348,994,275,988,264,1018,196" >
<area shape="poly" coords="1173,125,1176,116,1168,110,1163,101,1168,83,1167,75,1153,73,1148,61,1159,52,1165,46,1172,41,1192,33,1202,33,1213,33,1220,37,1233,38,1248,40,1259,54,1254,65,1227,71,1227,80,1218,93,1228,105,1231,116,1230,137,1228,152,1225,175,1217,184,1209,195,1195,219,1196,235,1197,245,1190,250,1180,248,1140,204,1130,191,1173,135,1173,125" >
<area shape="poly" coords="1269,1,1302,41,1320,59,1322,73,1316,86,1310,105,1310,114,1317,125,1324,133,1325,149,1322,179,1317,196,1311,207,1303,217,1292,207,1288,221,1284,238,1279,254,1281,270,1281,290,1290,294,1306,314,1316,334,1312,349,1311,363,1313,383,1295,407,1285,418,1284,429,1272,438,1274,458,1285,459,1336,463,1369,461,1457,465,1488,463,1513,467,1482,429,1493,406,1474,366,1475,330,1474,287,1469,276,1479,254,1478,235,1472,216,1469,183,1469,166,1475,149,1477,129,1473,123,1475,118,1482,85,1504,53,1536,3,1536,-1,1269,1" >
<area shape="poly" coords="1482,301,1516,347,1510,371,1526,396,1550,409,1568,418,1583,442,1614,470,1622,481,1633,479,1673,487,1709,480,1716,448,1724,369,1728,331,1739,296,1713,265,1699,250,1681,228,1652,233,1619,235,1584,237,1528,273,1482,301" >
<area shape="poly" coords="1719,222,1747,160,1751,143,1726,149,1724,132,1717,119,1712,97,1687,86,1636,33,1643,28,1687,47,1772,41,1823,2,1843,1,1858,35,1914,50,1976,37,2082,87,2080,100,1911,119,1879,141,1829,136,1836,158,1852,180,1859,200,1849,225,1825,238,1811,266,1819,284,1837,301,1843,304,1847,325,1823,309,1805,285,1797,263,1816,228,1829,220,1818,214,1790,201,1773,192,1762,180,1735,214,1719,222" >
<area shape="poly" coords="2051,147,2074,125,2080,118,2094,113,2107,106,2131,112,2169,84,2231,92,2254,107,2273,130,2274,147,2264,161,2265,179,2269,214,2235,215,2174,208,2189,172,2160,165,2140,161,2115,180,2102,198,2091,204,2071,208,2061,205,2053,197,2083,180,2094,172,2087,161,2065,168,2052,168,2051,147" >
<area shape="poly" coords="1847,298,1896,265,1988,240,2041,232,2044,253,2096,251,2082,273,2105,287,2091,329,2065,349,2079,377,2049,390,2032,397,2018,420,2070,456,2050,477,1986,437,1960,421,1957,460,1939,460,1908,408,1904,438,1871,448,1876,402,1857,410,1811,435,1803,430,1844,392,1864,359,1875,335,1865,324,1847,298" >
<area shape="poly" coords="2332,1,2523,1,2535,23,2548,38,2541,50,2534,69,2524,79,2528,101,2524,159,2511,208,2503,272,2482,295,2479,344,2452,393,2434,394,2419,427,2387,422,2368,407,2351,351,2341,300,2337,213,2330,201,2312,201,2308,170,2307,153,2326,143,2341,115,2348,90,2342,81,2338,64,2332,1" >
</map>
$('area').attr('href', '#');
$('.off-the-side').addClass('push-side');
$('.wall-writings').addClass('wall-writepos').prepend('<button class="close"><img src="x-icon.png" alt=""></button>').hide();
$('area').click(function(){$('#writing1').fadeIn('slow');return false;});
$('.close').click(function(){$(".wall-writings").fadeOut();});
Hope I understood the problem :)
I would place an href tag on each area like:
<map>
<area href="#div1" shape="poly" coords="287,230,301,244,319,251,329,252,340,252,347,252,338,246,336,237,344,233,344,229,345,225,356,227,362,229,376,230,385,235,393,242,396,250,403,254,408,248,414,239,419,231,424,224,429,222,433,233,432,248,428,263,422,272,422,279,410,286,396,288,388,291,385,293,390,296,393,305,396,316,400,318,407,320,414,325,416,332,420,343,415,352,414,360,408,369,401,374,405,387,409,399,407,409,408,412,402,414,368,365,357,374,358,390,359,403,354,409,343,415,337,416,323,370,294,362,268,327,264,274,287,230" >
</map>
<div id="some_div">Some text</div>
$('area').click(function(){var href = $(this).attr('href'); $(href).show(); return false;});
css
#some_div{display:none;}
I think this should work. If this is not what you intended please explain further
In jquery using the click event handler. How do I keep all the
elements from not show but only have one element show one at time to
what is related when I click on it?.
From what i can deduce from your html mapping, you are missing the id's attribute for the tag and your Jquery is actually targeting the whole image map.
the guilty code:
$('area').click(function(){$('#writing1').fadeIn('slow');return false;});
Because of that, all the elements would show when you clicked on any of the area map.

Categories