Перескакивает в начало страницы, A href="#" (Якорь)
На сайте установлен переключатель серий и при нажатии на выбор серии - перекидывает всю страницу наверх.
Пример можно посмотреть тут: http://dirfilms.net/serial/430-unive...a-2-sezon.html Как должно работать: http://ikinokz.net/13807-ostrov.html Код:
xfgiven_1kset]
<div id="serial_tab" class="serial_tab">
<div class="serial_tab_top"></div>
<div class="serial_tab_input">
<a href="#" rel="seria1" class="selected"><span>1</span></a>
[xfgiven_2kset]<a href="#" rel="seria2"><span>2</span></a>[/xfgiven_2kset]
[xfgiven_3kset]<a href="#" rel="seria3"><span>3</span></a>[/xfgiven_3kset]
[xfgiven_4kset]<a href="#" rel="seria4"><span>4</span></a>[/xfgiven_4kset]
[xfgiven_5kset]<a href="#" rel="seria5"><span>5</span></a>[/xfgiven_5kset]
[xfgiven_6kset]<a href="#" rel="seria6"><span>6</span></a>[/xfgiven_6kset]
[xfgiven_7kset]<a href="#" rel="seria7"><span>7</span></a>[/xfgiven_7kset]
[xfgiven_8kset]<a href="#" rel="seria8"><span>8</span></a>[/xfgiven_8kset]
[xfgiven_9kset]<a href="#" rel="seria9"><span>9</span></a>[/xfgiven_9kset]
[xfgiven_10kset]<a href="#" rel="seria10"><span>10</span></a>[/xfgiven_10kset]
[xfgiven_11kset]<a href="#" rel="seria11"><span>11</span></a>[/xfgiven_11kset]
[xfgiven_12kset]<a href="#" rel="seria12"><span>12</span></a>[/xfgiven_12kset]
[xfgiven_13kset]<a href="#" rel="seria13"><span>13</span></a>[/xfgiven_13kset]
[xfgiven_14kset]<a href="#" rel="seria14"><span>14</span></a>[/xfgiven_14kset]
[xfgiven_15kset]<a href="#" rel="seria15"><span>15</span></a>[/xfgiven_15kset]
[xfgiven_16kset]<a href="#" rel="seria16"><span>16</span></a>[/xfgiven_16kset]
[xfgiven_17kset]<a href="#" rel="seria17"><span>17</span></a>[/xfgiven_17kset]
[xfgiven_18kset]<a href="#" rel="seria18"><span>18</span></a>[/xfgiven_18kset]
[xfgiven_19kset]<a href="#" rel="seria19"><span>19</span></a>[/xfgiven_19kset]
[xfgiven_20kset]<a href="#" rel="seria20"><span>20</span></a>[/xfgiven_20kset]
[xfgiven_21kset]<a href="#" rel="seria21"><span>21</span></a>[/xfgiven_21kset]
[xfgiven_22kset]<a href="#" rel="seria22"><span>22</span></a>[/xfgiven_22kset]
[xfgiven_23kset]<a href="#" rel="seria23"><span>23</span></a>[/xfgiven_23kset]
[xfgiven_24kset]<a href="#" rel="seria24"><span>24</span></a>[/xfgiven_24kset]
[xfgiven_25kset]<a href="#" rel="seria25"><span>25</span></a>[/xfgiven_25kset]
[xfgiven_26kset]<a href="#" rel="seria26"><span>26</span></a>[/xfgiven_26kset]
[xfgiven_27kset]<a href="#" rel="seria27"><span>27</span></a>[/xfgiven_27kset]
[xfgiven_28kset]<a href="#" rel="seria28"><span>28</span></a>[/xfgiven_28kset]
[xfgiven_29kset]<a href="#" rel="seria29"><span>29</span></a>[/xfgiven_29kset]
[xfgiven_30kset]<a href="#" rel="seria30"><span>30</span></a>[/xfgiven_30kset]
</div>
</div>
|
Вот продолжение кода (Под доп поля (Плеера):
<div id="seria1" class="tabcontent" style="display: none;">
<object data="http://st.kset.kz/pl/pl.swf?v=5" type="application/x-shockwave-flash" width="570" height="350" name="flash_object" id="flash_object"><param name="bgcolor" value="#ffffff" /><param name="allowFullScreen" value="true" /><param name="allowScriptAccess" value="always" /><param name="movie" value="http://st.kset.kz/pl/pl.swf" /><param name="flashvars" value="st=http://kset.kz/v.php?id=[xfvalue_1kset]" /></object>
</div>
[xfgiven_2kset]<div id="seria2" style="display: none;">
<object data="http://st.kset.kz/pl/pl.swf?v=5" type="application/x-shockwave-flash" width="570" height="350" name="flash_object" id="flash_object"><param name="bgcolor" value="#ffffff" /><param name="allowFullScreen" value="true" /><param name="allowScriptAccess" value="always" /><param name="movie" value="http://st.kset.kz/pl/pl.swf" /><param name="flashvars" value="st=http://kset.kz/v.php?id=[xfvalue_2kset]" /></object>
</div>[/xfgiven_2kset]
[xfgiven_3kset]<div id="seria3" style="display: none;">
<object data="http://st.kset.kz/pl/pl.swf?v=5" type="application/x-shockwave-flash" width="570" height="350" name="flash_object" id="flash_object"><param name="bgcolor" value="#ffffff" /><param name="allowFullScreen" value="true" /><param name="allowScriptAccess" value="always" /><param name="movie" value="http://st.kset.kz/pl/pl.swf" /><param name="flashvars" value="st=http://kset.kz/v.php?id=[xfvalue_3kset]" /></object>
</div>[/xfgiven_3kset]
[xfgiven_4kset]<div id="seria4" style="display: none;">
<object data="http://st.kset.kz/pl/pl.swf?v=5" type="application/x-shockwave-flash" width="570" height="350" name="flash_object" id="flash_object"><param name="bgcolor" value="#ffffff" /><param name="allowFullScreen" value="true" /><param name="allowScriptAccess" value="always" /><param name="movie" value="http://st.kset.kz/pl/pl.swf" /><param name="flashvars" value="st=http://kset.kz/v.php?id=[xfvalue_4kset]" /></object>
</div>[/xfgiven_4kset]
[xfgiven_5kset]<div id="seria5" style="display: none;">
<object data="http://st.kset.kz/pl/pl.swf?v=5" type="application/x-shockwave-flash" width="570" height="350" name="flash_object" id="flash_object"><param name="bgcolor" value="#ffffff" /><param name="allowFullScreen" value="true" /><param name="allowScriptAccess" value="always" /><param name="movie" value="http://st.kset.kz/pl/pl.swf" /><param name="flashvars" value="st=http://kset.kz/v.php?id=[xfvalue_5kset]" /></object>
</div>[/xfgiven_5kset]
[xfgiven_6kset]<div id="seria6" style="display: none;">
<object data="http://st.kset.kz/pl/pl.swf?v=5" type="application/x-shockwave-flash" width="570" height="350" name="flash_object" id="flash_object"><param name="bgcolor" value="#ffffff" /><param name="allowFullScreen" value="true" /><param name="allowScriptAccess" value="always" /><param name="movie" value="http://st.kset.kz/pl/pl.swf" /><param name="flashvars" value="st=http://kset.kz/v.php?id=[xfvalue_6kset]" /></object>
</div>[/xfgiven_6kset]
[xfgiven_7kset]<div id="seria7" style="display: none;">
<object data="http://st.kset.kz/pl/pl.swf?v=5" type="application/x-shockwave-flash" width="570" height="350" name="flash_object" id="flash_object"><param name="bgcolor" value="#ffffff" /><param name="allowFullScreen" value="true" /><param name="allowScriptAccess" value="always" /><param name="movie" value="http://st.kset.kz/pl/pl.swf" /><param name="flashvars" value="st=http://kset.kz/v.php?id=[xfvalue_7kset]" /></object>
</div>[/xfgiven_7kset]
[xfgiven_8kset]<div id="seria8" style="display: none;">
<object data="http://st.kset.kz/pl/pl.swf?v=5" type="application/x-shockwave-flash" width="570" height="350" name="flash_object" id="flash_object"><param name="bgcolor" value="#ffffff" /><param name="allowFullScreen" value="true" /><param name="allowScriptAccess" value="always" /><param name="movie" value="http://st.kset.kz/pl/pl.swf" /><param name="flashvars" value="st=http://kset.kz/v.php?id=[xfvalue_8kset]" /></object>
</div>[/xfgiven_8kset]
[xfgiven_9kset]<div id="seria9" style="display: none;">
<object data="http://st.kset.kz/pl/pl.swf?v=5" type="application/x-shockwave-flash" width="570" height="350" name="flash_object" id="flash_object"><param name="bgcolor" value="#ffffff" /><param name="allowFullScreen" value="true" /><param name="allowScriptAccess" value="always" /><param name="movie" value="http://st.kset.kz/pl/pl.swf" /><param name="flashvars" value="st=http://kset.kz/v.php?id=[xfvalue_9kset]" /></object>
</div>[/xfgiven_9kset]
[xfgiven_10kset]<div id="seria10" style="display: none;">
<object data="http://st.kset.kz/pl/pl.swf?v=5" type="application/x-shockwave-flash" width="570" height="350" name="flash_object" id="flash_object"><param name="bgcolor" value="#ffffff" /><param name="allowFullScreen" value="true" /><param name="allowScriptAccess" value="always" /><param name="movie" value="http://st.kset.kz/pl/pl.swf" /><param name="flashvars" value="st=http://kset.kz/v.php?id=[xfvalue_10kset]" /></object>
</div>[/xfgiven_10kset]
<script type="text/javascript">
var countries=new ddtabcontent("serial_tab")
countries.setpersist(true)
countries.setselectedClassTarget("link") //"link" or "linkparent"
countries.init()
</script>
[/xfgiven_1kset]
|
Мне сказали вместо якоря # сделать так javascript:void(0);
Но после этого перестала выделяться выбранная серия в переключателе. <a href="javascript:void(0);" rel="seria1" class="selected"><span>1</span></a> [xfgiven_2kset]<a href="javascript:void(0);" rel="seria2"><span>2</span></a>[/xfgiven_2kset] [xfgiven_3kset]<a href="javascript:void(0);" rel="seria3"><span>3</span></a>[/xfgiven_3kset] [xfgiven_4kset]<a href="javascript:void(0);" rel="seria4"><span>4</span></a>[/xfgiven_4kset] [xfgiven_5kset]<a href="javascript:void(0);" rel="seria5"><span>5</span></a>[/xfgiven_5kset] [xfgiven_6kset]<a href="javascript:void(0);" rel="seria6"><span>6</span></a>[/xfgiven_6kset] [xfgiven_7kset]<a href="javascript:void(0);" rel="seria7"><span>7</span></a>[/xfgiven_7kset] [xfgiven_8kset]<a href="javascript:void(0);" rel="seria8"><span>8</span></a>[/xfgiven_8kset] [xfgiven_9kset]<a href="javascript:void(0);" rel="seria9"><span>9</span></a>[/xfgiven_9kset] [xfgiven_10kset]<a href="javascript:void(0);" rel="seria10"><span>10</span></a>[/xfgiven_10kset] [xfgiven_11kset]<a href="javascript:void(0);" rel="seria11"><span>11</span></a>[/xfgiven_11kset] [xfgiven_12kset]<a href="javascript:void(0);" rel="seria12"><span>12</span></a>[/xfgiven_12kset] [xfgiven_13kset]<a href="javascript:void(0);" rel="seria13"><span>13</span></a>[/xfgiven_13kset] [xfgiven_14kset]<a href="javascript:void(0);" rel="seria14"><span>14</span></a>[/xfgiven_14kset] [xfgiven_15kset]<a href="javascript:void(0);" rel="seria15"><span>15</span></a>[/xfgiven_15kset] [xfgiven_16kset]<a href="javascript:void(0);" rel="seria16"><span>16</span></a>[/xfgiven_16kset] [xfgiven_17kset]<a href="javascript:void(0);" rel="seria17"><span>17</span></a>[/xfgiven_17kset] [xfgiven_18kset]<a href="javascript:void(0);" rel="seria18"><span>18</span></a>[/xfgiven_18kset] [xfgiven_19kset]<a href="javascript:void(0);" rel="seria19"><span>19</span></a>[/xfgiven_19kset] [xfgiven_20kset]<a href="javascript:void(0);" rel="seria20"><span>20</span></a>[/xfgiven_20kset] [xfgiven_21kset]<a href="javascript:void(0);" rel="seria21"><span>21</span></a>[/xfgiven_21kset] [xfgiven_22kset]<a href="javascript:void(0);" rel="seria22"><span>22</span></a>[/xfgiven_22kset] [xfgiven_23kset]<a href="javascript:void(0);" rel="seria23"><span>23</span></a>[/xfgiven_23kset] [xfgiven_24kset]<a href="javascript:void(0);" rel="seria24"><span>24</span></a>[/xfgiven_24kset] [xfgiven_25kset]<a href="javascript:void(0);" rel="seria25"><span>25</span></a>[/xfgiven_25kset] [xfgiven_26kset]<a href="javascript:void(0);" rel="seria26"><span>26</span></a>[/xfgiven_26kset] [xfgiven_27kset]<a href="javascript:void(0);" rel="seria27"><span>27</span></a>[/xfgiven_27kset] [xfgiven_28kset]<a href="javascript:void(0);" rel="seria28"><span>28</span></a>[/xfgiven_28kset] [xfgiven_29kset]<a href="javascript:void(0);" rel="seria29"><span>29</span></a>[/xfgiven_29kset] [xfgiven_30kset]<a href="javascript:void(0);" rel="seria30"><span>30</span></a>[/xfgiven_30kset] |
В консоли Браузера выводятся такие ошибки:
Uncaught TypeError: Cannot read property 'style' of null tabcontent.js:96 ddtabcontent.expandsubcontent tabcontent.js:96 ddtabcontent.expandtab tabcontent.js:83 tabs.(anonymous function).onclick Вот строки tabcontent.js:96: subcontent.style.display=(subcontent.id==subcontentid)? "block" : "none" //"show" or hide sub content based on matching id attr value } }, tabcontent.js:83: this.expandsubcontent(subcontentid) Полный tabcontent.js:
//** Tab Content script v2.0- © Dynamic Drive DHTML code library ([url]http://www.dynamicdrive.com[/url])
//** Updated Oct 7th, 07 to version 2.0. Contains numerous improvements:
// -Added Auto Mode: Script auto rotates the tabs based on an interval, until a tab is explicitly selected
// -Ability to expand/contract arbitrary DIVs on the page as the tabbed content is expanded/ contracted
// -Ability to dynamically select a tab either based on its position within its peers, or its ID attribute (give the target tab one 1st)
// -Ability to set where the CSS classname "selected" get assigned- either to the target tab's link ("A"), or its parent container
//** Updated Feb 18th, 08 to version 2.1: Adds a "tabinstance.cycleit(dir)" method to cycle forward or backward between tabs dynamically
//** Updated April 8th, 08 to version 2.2: Adds support for expanding a tab using a URL parameter (ie: [url]http://mysite.com/tabcontent.htm?tabinterfaceid=0[/url])
////NO NEED TO EDIT BELOW////////////////////////
function ddtabcontent(tabinterfaceid){
this.tabinterfaceid=tabinterfaceid //ID of Tab Menu main container
this.tabs=document.getElementById(tabinterfaceid).getElementsByTagName("a") //Get all tab links within container
this.enabletabpersistence=true
this.hottabspositions=[] //Array to store position of tabs that have a "rel" attr defined, relative to all tab links, within container
this.currentTabIndex=0 //Index of currently selected hot tab (tab with sub content) within hottabspositions[] array
this.subcontentids=[] //Array to store ids of the sub contents ("rel" attr values)
this.revcontentids=[] //Array to store ids of arbitrary contents to expand/contact as well ("rev" attr values)
this.selectedClassTarget="link" //keyword to indicate which target element to assign "selected" CSS class ("linkparent" or "link")
}
ddtabcontent.getCookie=function(Name){
var re=new RegExp(Name+"=[^;]+", "i"); //construct RE to search for target name/value pair
if (document.cookie.match(re)) //if cookie found
return document.cookie.match(re)[0].split("=")[1] //return its value
return ""
}
ddtabcontent.setCookie=function(name, value){
document.cookie = name+"="+value+";path=/" //cookie value is domain wide (path=/)
}
ddtabcontent.prototype={
expandit:function(tabid_or_position){ //PUBLIC function to select a tab either by its ID or position(int) within its peers
this.cancelautorun() //stop auto cycling of tabs (if running)
var tabref=""
try{
if (typeof tabid_or_position=="string" && document.getElementById(tabid_or_position).getAttribute("rel")) //if specified tab contains "rel" attr
tabref=document.getElementById(tabid_or_position)
else if (parseInt(tabid_or_position)!=NaN && this.tabs[tabid_or_position].getAttribute("rel")) //if specified tab contains "rel" attr
tabref=this.tabs[tabid_or_position]
}
catch(err){alert("Invalid Tab ID or position entered!")}
if (tabref!="") //if a valid tab is found based on function parameter
this.expandtab(tabref) //expand this tab
},
cycleit:function(dir, autorun){ //PUBLIC function to move foward or backwards through each hot tab (tabinstance.cycleit('foward/back') )
if (dir=="next"){
var currentTabIndex=(this.currentTabIndex<this.hottabspositions.length-1)? this.currentTabIndex+1 : 0
}
else if (dir=="prev"){
var currentTabIndex=(this.currentTabIndex>0)? this.currentTabIndex-1 : this.hottabspositions.length-1
}
if (typeof autorun=="undefined") //if cycleit() is being called by user, versus autorun() function
this.cancelautorun() //stop auto cycling of tabs (if running)
this.expandtab(this.tabs[this.hottabspositions[currentTabIndex]])
},
setpersist:function(bool){ //PUBLIC function to toggle persistence feature
this.enabletabpersistence=bool
},
setselectedClassTarget:function(objstr){ //PUBLIC function to set which target element to assign "selected" CSS class ("linkparent" or "link")
this.selectedClassTarget=objstr || "link"
},
getselectedClassTarget:function(tabref){ //Returns target element to assign "selected" CSS class to
return (this.selectedClassTarget==("linkparent".toLowerCase()))? tabref.parentNode : tabref
},
urlparamselect:function(tabinterfaceid){
var result=window.location.search.match(new RegExp(tabinterfaceid+"=(\\d+)", "i")) //check for "?tabinterfaceid=2" in URL
return (result==null)? null : parseInt(RegExp.$1) //returns null or index, where index (int) is the selected tab's index
},
expandtab:function(tabref){
var subcontentid=tabref.getAttribute("rel") //Get id of subcontent to expand
//Get "rev" attr as a string of IDs in the format ",john,george,trey,etc," to easily search through
var associatedrevids=(tabref.getAttribute("rev"))? ","+tabref.getAttribute("rev").replace(/\s+/, "")+"," : ""
this.expandsubcontent(subcontentid)
this.expandrevcontent(associatedrevids)
for (var i=0; i<this.tabs.length; i++){ //Loop through all tabs, and assign only the selected tab the CSS class "selected"
this.getselectedClassTarget(this.tabs[i]).className=(this.tabs[i].getAttribute("rel")==subcontentid)? "selected" : ""
}
if (this.enabletabpersistence) //if persistence enabled, save selected tab position(int) relative to its peers
ddtabcontent.setCookie(this.tabinterfaceid, tabref.tabposition)
this.setcurrenttabindex(tabref.tabposition) //remember position of selected tab within hottabspositions[] array
},
expandsubcontent:function(subcontentid){
for (var i=0; i<this.subcontentids.length; i++){
var subcontent=document.getElementById(this.subcontentids[i]) //cache current subcontent obj (in for loop)
subcontent.style.display=(subcontent.id==subcontentid)? "block" : "none" //"show" or hide sub content based on matching id attr value
}
},
expandrevcontent:function(associatedrevids){
var allrevids=this.revcontentids
for (var i=0; i<allrevids.length; i++){ //Loop through rev attributes for all tabs in this tab interface
//if any values stored within associatedrevids matches one within allrevids, expand that DIV, otherwise, contract it
document.getElementById(allrevids[i]).style.display=(associatedrevids.indexOf(","+allrevids[i]+",")!=-1)? "block" : "none"
}
},
setcurrenttabindex:function(tabposition){ //store current position of tab (within hottabspositions[] array)
for (var i=0; i<this.hottabspositions.length; i++){
if (tabposition==this.hottabspositions[i]){
this.currentTabIndex=i
break
}
}
},
autorun:function(){ //function to auto cycle through and select tabs based on a set interval
this.cycleit('next', true)
},
cancelautorun:function(){
if (typeof this.autoruntimer!="undefined")
clearInterval(this.autoruntimer)
},
init:function(automodeperiod){
var persistedtab=ddtabcontent.getCookie(this.tabinterfaceid) //get position of persisted tab (applicable if persistence is enabled)
var selectedtab=-1 //Currently selected tab index (-1 meaning none)
var selectedtabfromurl=this.urlparamselect(this.tabinterfaceid) //returns null or index from: tabcontent.htm?tabinterfaceid=index
this.automodeperiod=automodeperiod || 0
for (var i=0; i<this.tabs.length; i++){
this.tabs[i].tabposition=i //remember position of tab relative to its peers
if (this.tabs[i].getAttribute("rel")){
var tabinstance=this
this.hottabspositions[this.hottabspositions.length]=i //store position of "hot" tab ("rel" attr defined) relative to its peers
this.subcontentids[this.subcontentids.length]=this.tabs[i].getAttribute("rel") //store id of sub content ("rel" attr value)
this.tabs[i].onclick=function(){
tabinstance.expandtab(this)
tabinstance.cancelautorun() //stop auto cycling of tabs (if running)
return false
}
if (this.tabs[i].getAttribute("rev")){ //if "rev" attr defined, store each value within "rev" as an array element
this.revcontentids=this.revcontentids.concat(this.tabs[i].getAttribute("rev").split(/\s*,\s*/))
}
if (selectedtabfromurl==i || this.enabletabpersistence && selectedtab==-1 && parseInt(persistedtab)==i || !this.enabletabpersistence && selectedtab==-1 && this.getselectedClassTarget(this.tabs[i]).className=="selected"){
selectedtab=i //Selected tab index, if found
}
}
} //END for loop
if (selectedtab!=-1) //if a valid default selected tab index is found
this.expandtab(this.tabs[selectedtab]) //expand selected tab (either from URL parameter, persistent feature, or class="selected" class)
else //if no valid default selected index found
this.expandtab(this.tabs[this.hottabspositions[0]]) //Just select first tab that contains a "rel" attr
if (parseInt(this.automodeperiod)>500 && this.hottabspositions.length>1){
this.autoruntimer=setInterval(function(){tabinstance.autorun()}, this.automodeperiod)
}
} //END int() function
} //END Prototype assignment
|
Полный tabcontent.css:
/* ######### CSS for Shade Tabs. Remove if not using ######### */
.shadetabs {margin-left:10px;height:25px;width: 1000px; float:left;}
.shadetabs a.selected {padding-left: 2px; display: block;float:left;font:12px Verdana; color:#2c2c2c; text-decoration: none; height: 25px; background:url(/images/fulltab_02.jpg) top right no-repeat;padding-right:48px;outline:none; }
.shadetabs a.selected span {display:block; line-height:15px; background:url(/images/fulltab_01.jpg) no-repeat;padding:4px 7px 6px 47px;}
.shadetabs a.selected:hover { background-position:100% -25px; text-decoration: none;}
.shadetabs a.selected:hover span { background-position:0% -25px;}
.shadetabs a {padding-left: 2px; display: block;float:left;font:12px Verdana; color:#2c2c2c; text-decoration: none; height: 25px; background:url(/images/fulltab_02.jpg) no-repeat 100% -25px;padding-right:48px;outline:none;margin:4px 0 0 0px;}
.shadetabs a span {display:block; line-height:15px; background:url(/images/fulltab_01.jpg) no-repeat 0% -25px;padding:4px 7px 6px 47px;}
.shadetabs a:hover { background:url(/images/fulltab_02.jpg) top right no-repeat; }
.shadetabs a:hover span {background:url(/images/fulltab_01.jpg) no-repeat;}
.tabcontent{
display:none;
}
@media print {
.tabcontent {
display:block !important;
}
}
|
Вопрос решен!Тема закрыта!
|
| Часовой пояс GMT +3, время: 01:13. |