View Full Version : سوال: اسکریپت ajax یا js برای lightbox
shahrooz_tk
دوشنبه 30 اردیبهشت 1387, 12:29 عصر
سلام .
من یک لایت باکس دارم اینم آدرسش : http://www.lokeshdhakar.com/projects/lightbox2/ ، چه کاری باید انجام بدم تا این لایت باکس به صورت onload page باشه ، یعنی اینکه تا وارد صفحه می شه اجرا شه .
با تشکر .
vahid4134
دوشنبه 30 اردیبهشت 1387, 12:39 عصر
<body onload="func()">
shahrooz_tk
دوشنبه 30 اردیبهشت 1387, 12:47 عصر
میشه یه نگاهی به این بندازید :
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en">
<head>
<title>Lightbox JS v2.0 | Test Page</title>
<link rel="stylesheet" href="css/lightbox.css" type="text/css" media="screen" />
<script src="js/prototype.js" type="text/javascript"></script>
<script src="js/scriptaculous.js?load=effects,builder" type="text/javascript"></script>
<script src="js/lightbox.js" type="text/javascript"></script>
<style type="text/css">
body{ color: #333; font: 13px 'Lucida Grande', Verdana, sans-serif; }
</style>
</head>
<body>
<h1><a href="http://www.lokeshdhakar.com/projects/lightbox2/">Lightbox JS <em>v2.04</em></a></h1>
<p><a href="http://www.lokeshdhakar.com">by Lokesh Dhakar</a></p>
<h2>Example</h2>
<a href="images/image-1.jpg" rel="lightbox"><img src="images/thumb-1.jpg" width="100" height="40" alt="" /></a>
<h2>How to Use:</h2>
<h3>Part 1 - Setup</h3>
<ol>
<li>Lightbox v2.0 uses the Prototype Framework and Scriptaculous Effects Library. You will need to include these three Javascript files in your header.
<pre><code><script type="text/javascript" src="js/prototype.js"></script>
<script type="text/javascript" src="js/scriptaculous.js?load=effects,builder"></script>
<script type="text/javascript" src="js/lightbox.js"></script>
</code></pre>
</li>
<li>Include the Lightbox CSS file (or append your active stylesheet with the Lightbox styles).
<pre><code><link rel="stylesheet" href="css/lightbox.css" type="text/css" media="screen" />
</code></pre>
</li>
<li>Check the CSS and make sure the referenced <code>prevlabel.gif</code> and <code>nextlabel.gif</code> files are in the right location. Also, make sure the <code>loading.gif</code> and <code>closelabel.gif</code> files as referenced near the top of the <code>lightbox.js</code> file are in the right location.</li>
</ol>
<h3>Part 2 - Activate</h3>
<ol>
<li>Add a <code>rel="lightbox"</code> attribute to any link tag to activate the lightbox. For example:
<pre><code><a href="images/image-1.jpg" rel="lightbox" title="my caption">image #1</a>
</code></pre>
<em>Optional: </em>Use the <code>title</code> attribute if you want to show a caption. </li>
<li>If you have a set of related images that you would like to group, follow step one but additionally include a group name between square brackets in the rel attribute. For example:
<pre><code><a href="images/image-1.jpg" rel="lightbox[roadtrip]">image #1</a>
<a href="images/image-2.jpg" rel="lightbox[roadtrip]">image #2</a>
<a href="images/image-3.jpg" rel="lightbox[roadtrip]">image #3</a>
</code></pre>
No limits to the number of image sets per page or how many images are allowed in each set. Go nuts!</li>
</ol>
</body>
</html>
twelve
دوشنبه 30 اردیبهشت 1387, 13:57 عصر
میشه یه نگاهی به این بندازید :
خب ؟ مشکل کجاست؟
shahrooz_tk
دوشنبه 30 اردیبهشت 1387, 14:03 عصر
مشکل اینه که نمی خوام روی تصویر کلیک بشه تا script اجرا شه . می خوام onload باشه .
twelve
دوشنبه 30 اردیبهشت 1387, 14:54 عصر
شما یک کد html قرار دادید با 3 تا منبع اسکریپت ، اصلا مشخص نیست چی رو میخواید onload اجرا کنید ؟!
به هر حال چیزی که قراره اجرا بشه باید یک تابع باشه که در یکی از این سه تا منبع قرار داره ، واسه اینم میتونید در تگ <head> این رو بنویسید :
window.onload(نام تابع)
shahrooz_tk
دوشنبه 30 اردیبهشت 1387, 18:27 عصر
نمونه اسکریپتی که منظور ام است اینه :
http://www.neypatogh.com/
حالا با این شکل و شمایل که فایل و براتون پیوست می کنم . ( اسکریپتی که در زمان کلیک روی عکس اتفاق می افته )
vahid4134
دوشنبه 30 اردیبهشت 1387, 20:51 عصر
اصلا عادت ندارم کد بزارم ها
ولی اینبار حق بهت می دادم که اگر اطلاعات خوبی از javascript نداشته باشی نمی تونستی کاری کنی
خودت من فقط index.html رو تغییر دادم که کدش به صورت زیر هست
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en">
<head>
<title>Lightbox JS v2.0 | Test Page</title>
<link rel="stylesheet" href="css/lightbox.css" type="text/css" media="screen" />
<script src="js/prototype.js" type="text/javascript"></script>
<script src="js/scriptaculous.js?load=effects,builder" type="text/javascript"></script>
<script src="js/lightbox.js" type="text/javascript"></script>
<style type="text/css">
body{ color: #333; font: 13px 'Lucida Grande', Verdana, sans-serif; }
</style>
<script type="text/javascript">
var autoShow=function(){
var target=document.getElementById('autoshow');
var newLightbox=new Lightbox;
newLightbox.start(target);
}
</script>
</head>
<body onload="autoShow()">
<h1><a href="http://www.lokeshdhakar.com/projects/lightbox2/">Lightbox JS <em>v2.04</em></a></h1>
<p><a href="http://www.lokeshdhakar.com">by Lokesh Dhakar</a></p>
<h2>Example</h2>
<a href="images/image-1.jpg" id='autoshow' rel="lightbox"><img src="images/thumb-1.jpg" width="100" height="40" alt="" /></a>
<h2>How to Use:</h2>
<h3>Part 1 - Setup</h3>
<ol>
<li>Lightbox v2.0 uses the Prototype Framework and Scriptaculous Effects Library. You will need to include these three Javascript files in your header.
<pre><code><script type="text/javascript" src="js/prototype.js"></script>
<script type="text/javascript" src="js/scriptaculous.js?load=effects,builder"></script>
<script type="text/javascript" src="js/lightbox.js"></script>
</code></pre>
</li>
<li>Include the Lightbox CSS file (or append your active stylesheet with the Lightbox styles).
<pre><code><link rel="stylesheet" href="css/lightbox.css" type="text/css" media="screen" />
</code></pre>
</li>
<li>Check the CSS and make sure the referenced <code>prevlabel.gif</code> and <code>nextlabel.gif</code> files are in the right location. Also, make sure the <code>loading.gif</code> and <code>closelabel.gif</code> files as referenced near the top of the <code>lightbox.js</code> file are in the right location.</li>
</ol>
<h3>Part 2 - Activate</h3>
<ol>
<li>Add a <code>rel="lightbox"</code> attribute to any link tag to activate the lightbox. For example:
<pre><code><a href="images/image-1.jpg" rel="lightbox" title="my caption">image #1</a>
</code></pre>
<em>Optional: </em>Use the <code>title</code> attribute if you want to show a caption. </li>
<li>If you have a set of related images that you would like to group, follow step one but additionally include a group name between square brackets in the rel attribute. For example:
<pre><code><a href="images/image-1.jpg" rel="lightbox[roadtrip]">image #1</a>
<a href="images/image-2.jpg" rel="lightbox[roadtrip]">image #2</a>
<a href="images/image-3.jpg" rel="lightbox[roadtrip]">image #3</a>
</code></pre>
No limits to the number of image sets per page or how many images are allowed in each set. Go nuts!</li>
</ol>
</body>
</html>
shahrooz_tk
دوشنبه 30 اردیبهشت 1387, 21:26 عصر
اصلا عادت ندارم کد بزارم ها
ولی اینبار حق بهت می دادم که اگر اطلاعات خوبی از javascript نداشته باشی نمی تونستی کاری کنی
خودت من فقط index.html رو تغییر دادم که کدش به صورت زیر هست
این که درست عمل نمی کنه !
vBulletin® v4.2.5, Copyright ©2000-1404, Jelsoft Enterprises Ltd.