JavaScript AND TemplatePower
shibble - 28/04/2006 12:18 (laatste wijziging 28/04/2006 12:18)
MySQL interesse
Hallo allemaal ik gebruik TemplatePower en ik wil JavaScript erin toepassen maarh et wilt neit helemaal werken weet iemand de oplossing?
sponsors.tpl:
<div id="headsponsor">
<h2><span>Head sponsors</span></h2>
<div id="headsponsor_content">
<!-- START BLOCK : headsponsors -->
<a href="index.php?p=sponsors&sid={sid}" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage('{sponsorImage}', '', 'tpl/images/sponsors/{sponsorImage}2.jpg',1)"><img src="tpl/images/sponsors/{sponsorImage}.jpg" name="{sponsorImage}" width="150" height="75" border="0" id="{sponsorImage}"></a>
<!-- END BLOCK : headsponsors -->
</div>
</div>
<div class="clearthis"> </div>
<div id="mainsponsor">
<h2><span>Main sponsors</span></h2>
<div id="mainsponsor_content">
<!-- START BLOCK : mainsponsors -->
<a href="index.php?p=sponsors&sid={sid}" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage('{sponsorImage}', '', 'tpl/images/sponsors/{sponsorImage}2.jpg',1)"><img src="tpl/images/sponsors/{sponsorImage}.jpg" name="{sponsorImage}" width="150" height="75" border="0" id="{sponsorImage}"></a>
<!-- END BLOCK : mainsponsors -->
</div>
</div>
<div class="clearthis"> </div>
<div id="sponsor">
<h2><span>Sponsor</span></h2>
<div id="sponsor_content">
<!-- START BLOCK : sponsors -->
<a href="index.php?p=sponsors&sid={sid}" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage('{sponsorImage}', '', 'tpl/images/sponsors/{sponsorImage}2.jpg',1)"><img src="tpl/images/sponsors/{sponsorImage}.jpg" name="{sponsorImage}" width="150" height="75" border="0" id="{sponsorImage}"></a>
<!-- END BLOCK : sponsors -->
</div>
</div>
<div class="clearthis"> </div>
<div id="partner">
<h2><span>Partner</span></h2>
<div id="partner_content">
<!-- START BLOCK : partners -->
<a href="index.php?p=sponsors&sid={sid}" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage('{sponsorImage}', '', 'tpl/images/sponsors/{sponsorImage}2.jpg',1)"><img src="tpl/images/sponsors/{sponsorImage}.jpg" name="{sponsorImage}" width="150" height="75" border="0" id="{sponsorImage}"></a>
<!-- END BLOCK : partners -->
</div>
</div>
< div id= "headsponsor" >
< h2>< span> Head sponsors</ span></ h2>
< div id= "headsponsor_content" >
<!-- START BLOCK : headsponsors -->
< a href= "index.php?p=sponsors&sid={sid}" onmouseout= "MM_swapImgRestore()" onmouseover= "MM_swapImage('{sponsorImage}', '', 'tpl/images/sponsors/{sponsorImage}2.jpg',1)" >< img src= "tpl/images/sponsors/{sponsorImage}.jpg" name= "{sponsorImage}" width= "150" height= "75" border= "0" id= "{sponsorImage}" ></ a>
<!-- END BLOCK
: headsponsors
--> </ div>
</ div>
< div class = "clearthis" >& nbsp;</ div>
< div id= "mainsponsor" >
< h2>< span> Main sponsors</ span></ h2>
< div id= "mainsponsor_content" >
<!-- START BLOCK : mainsponsors -->
< a href= "index.php?p=sponsors&sid={sid}" onmouseout= "MM_swapImgRestore()" onmouseover= "MM_swapImage('{sponsorImage}', '', 'tpl/images/sponsors/{sponsorImage}2.jpg',1)" >< img src= "tpl/images/sponsors/{sponsorImage}.jpg" name= "{sponsorImage}" width= "150" height= "75" border= "0" id= "{sponsorImage}" ></ a>
<!-- END BLOCK
: mainsponsors
-->
</ div>
</ div>
< div class = "clearthis" >& nbsp;</ div>
< div id= "sponsor" >
< h2>< span> Sponsor</ span></ h2>
< div id= "sponsor_content" >
<!-- START BLOCK : sponsors -->
< a href= "index.php?p=sponsors&sid={sid}" onmouseout= "MM_swapImgRestore()" onmouseover= "MM_swapImage('{sponsorImage}', '', 'tpl/images/sponsors/{sponsorImage}2.jpg',1)" >< img src= "tpl/images/sponsors/{sponsorImage}.jpg" name= "{sponsorImage}" width= "150" height= "75" border= "0" id= "{sponsorImage}" ></ a>
<!-- END BLOCK
: sponsors
--> </ div>
</ div>
< div class = "clearthis" >& nbsp;</ div>
< div id= "partner" >
< h2>< span> Partner</ span></ h2>
< div id= "partner_content" >
<!-- START BLOCK : partners -->
< a href= "index.php?p=sponsors&sid={sid}" onmouseout= "MM_swapImgRestore()" onmouseover= "MM_swapImage('{sponsorImage}', '', 'tpl/images/sponsors/{sponsorImage}2.jpg',1)" >< img src= "tpl/images/sponsors/{sponsorImage}.jpg" name= "{sponsorImage}" width= "150" height= "75" border= "0" id= "{sponsorImage}" ></ a>
<!-- END BLOCK
: partners
--> </ div>
</ div>
ik heb in me index.tpl staan:
<script type="javascript" src="tpl/functions.js"></script>
< script type= "javascript" src= "tpl/functions.js" ></ script>
en dat klopt allemaal.
me functions.js:
function MM_swapImgRestore() { //v3.0
var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}
function MM_preloadImages() { //v3.0
var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}
function MM_findObj(n, d) { //v4.01
var p,i,x; if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
if(!x && d.getElementById) x=d.getElementById(n); return x;
}
function MM_swapImage() { //v3.0
var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}
function MM_swapImgRestore( ) { //v3.0
var i, x, a= document. MM_sr; for ( i= 0 ; a&& i< a. length&& ( x= a[ i] ) && x. oSrc; i++ ) x. src= x. oSrc;
}
function MM_preloadImages( ) { //v3.0
var d
= document
; if ( d
. images
) { if ( ! d
. MM_p
) d
. MM_p
= new Array ( ) ; var i, j= d. MM_p. length, a= MM_preloadImages. arguments; for ( i= 0 ; i< a. length; i++ )
if ( a[ i] . indexOf( "#" ) != 0 ) { d. MM_p[ j] = new Image; d. MM_p[ j++ ] . src= a[ i] ; } }
}
function MM_findObj( n, d) { //v4.01
var p, i, x; if ( ! d) d= document; if ( ( p= n. indexOf( "?" ) ) > 0 && parent. frames. length) {
d= parent. frames[ n. substring( p+ 1 ) ] . document; n= n. substring( 0 , p) ; }
if ( ! ( x= d[ n] ) && d. all) x= d. all[ n] ; for ( i= 0 ;! x&& i< d. forms. length; i++ ) x= d. forms[ i] [ n] ;
for ( i= 0 ;! x&& d. layers&& i< d. layers. length; i++ ) x= MM_findObj( n, d. layers[ i] . document) ;
if ( ! x && d. getElementById) x= d. getElementById( n) ; return x;
}
function MM_swapImage( ) { //v3.0
var i
, j
= 0 , x
, a
= MM_swapImage
. arguments
; document
. MM_sr
= new Array ; for ( i
= 0 ; i
< ( a
. length
- 2 ) ; i
+= 3 ) if ( ( x= MM_findObj( a[ i] ) ) != null ) { document. MM_sr[ j++ ] = x; if ( ! x. oSrc) x. oSrc= x. src; x. src= a[ i+ 2 ] ; }
}
weet iemand hier de oplossing op?
12 antwoorden
Gesponsorde links
shibble - 28/04/2006 12:34
MySQL interesse
wat werkt er wel...
alles behalve de javascript.
dus als ik over het plaatje ga gaat hij niet naar dat andere plaatje
alleen de javascript zelf werkt niet.
BramBo - 28/04/2006 12:41
JS gevorderde
Alleen de name='{sponserimage}' is genoeg
Verder ziet het er naar mijn idee goed uit Kijk in je bron of je geen dubbele namen gebruikt.. Je kan je javascript console oproepen (In FF Extra-> Javascript Console)
Zo word het aangeroepen naar mijn idee :
<a href="link.htm" onMouseOut="MM_swapImgRestore()"
onMouseOver="MM_swapImage('i1','','ib.jpg',1)"><img name="i1"
border="0" src="ia.jpg"></a>
< a href= "link.htm" onMouseOut= "MM_swapImgRestore()"
onMouseOver= "MM_swapImage('i1','','ib.jpg',1)" >< img name= "i1"
border= "0" src= "ia.jpg" ></ a>
Slipie - 28/04/2006 12:45
PHP beginner
En wat heeft dat met Template Power te maken?
Check gewoon of je paden goed zijn.
En anders zijn foutmeldingen ook wel handig
(hint check je javascript errors in de javascript console van firefox)
Thomas - 28/04/2006 12:49
Moderator
Mijn ervaring met JavaScript en relatieve paden is dat je verschillend gedrag heb in bijvoorbeeld IE en FF (bijvoorbeeld bij het openen van popups). Reden te meer om inderdaad even de paden te controleren, en desnoods met absolute paden (volledige adressen) te werken.
shibble - 28/04/2006 12:50
MySQL interesse
TY @ Slipie & BramBo
en ja ik heb alles gecheckt is goed en heb net die van mm_swapimage gefixt maar daar krijg ik nu dit bij:
missing ; before statement
dielinkshizzle
MM_swapImage() 'tind', '', 'tpl/images/sponsors/tind2.jpg', 1)
en zon streep met pijltje naar tind (die tind na swapimage)
@Slipie ik ben niet goed in javascript namelijk daarom vraag ik om hulp.
BramBo - 28/04/2006 13:03
JS gevorderde
Zou je eens een stukje broncode kunnen posten dus een stuk dat door php heen is gehaald en wat je werkelijk ziet in de browser..
Zoals FangorN ook al aan haalde is het geen slecht idee om met absolute paden te werken persoonlijk werkelijk altijd met een global indentifier, om het zomaar te benoemen, dus ini php declareer je het domein en path naar je website :
$info['website'] = "http://www.domein.nl/la";
// en dan deze terug roepen in je template power
$info [ 'website' ] = "http://www.domein.nl/la" ;
// en dan deze terug roepen in je template power
shibble - 28/04/2006 13:06
MySQL interesse
ik vat het niet helemaal BramBo, TemplatePower houdt php en html gescheiden dus met die zin "ou je eens een stukje broncode kunnen posten dus een stuk dat door php heen is gehaald en wat je werkelijk ziet in de browser.." snap ik niet helemaaal :S
BramBo - 28/04/2006 13:09
JS gevorderde
Oke, dus gewoon de website openen in je browser broncode in kijken en daar een stukje van posten of alternatievelijk de url geven waar je bezig bent met je website..
shibble - 28/04/2006 13:13
MySQL interesse
<div id="mainsponsor">
<h2><span>Main sponsors</span></h2>
<div id="mainsponsor_content">
<a href="index.php?p=sponsors&sid=2" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage('tind', '', 'tpl/images/sponsors/tind2.jpg',1)"><img src="tpl/images/sponsors/tind.jpg" name="tind" width="150" height="75" border="0" id="tind"></a>
<a href="index.php?p=sponsors&sid=1" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage('universehosting', '', 'tpl/images/sponsors/universehosting2.jpg',1)"><img src="tpl/images/sponsors/universehosting.jpg" name="universehosting" width="150" height="75" border="0" id="universehosting"></a>
</div>
</div>
< div id= "mainsponsor" >
< h2>< span> Main sponsors</ span></ h2>
< div id= "mainsponsor_content" >
< a href= "index.php?p=sponsors&sid=2" onmouseout= "MM_swapImgRestore()" onmouseover= "MM_swapImage('tind', '', 'tpl/images/sponsors/tind2.jpg',1)" >< img src= "tpl/images/sponsors/tind.jpg" name= "tind" width= "150" height= "75" border= "0" id= "tind" ></ a>
< a href= "index.php?p=sponsors&sid=1" onmouseout= "MM_swapImgRestore()" onmouseover= "MM_swapImage('universehosting', '', 'tpl/images/sponsors/universehosting2.jpg',1)" >< img src= "tpl/images/sponsors/universehosting.jpg" name= "universehosting" width= "150" height= "75" border= "0" id= "universehosting" ></ a>
</ div>
</ div>
je bedoelt dat stukkie?:p
BramBo - 28/04/2006 13:31
JS gevorderde
Vreemd, probeer toch eens absolute urls te gebruiken..
; na de functies gebruiken.
Of ik ben aan het slapen of er scheelt echt niets aan de aanroep van de functies...
Je kan altijd :
<a href="index.php?p=sponsors&sid=1" onmouseout="universehosting.src='tpl/images/sponsors/universehosting.jpg';'" onmouseover="universehosting.src='tpl/images/sponsors/universehosting2.jpg';">
<img src="tpl/images/sponsors/universehosting.jpg" name="universehosting" width="150" height="75" border="0">
</a>
< a href= "index.php?p=sponsors&sid=1" onmouseout= "universehosting.src='tpl/images/sponsors/universehosting.jpg';'" onmouseover= "universehosting.src='tpl/images/sponsors/universehosting2.jpg';" >
< img src= "tpl/images/sponsors/universehosting.jpg" name= "universehosting" width= "150" height= "75" border= "0" >
</ a>
gebruiken dit zal zonder twijfel werken
shibble - 28/04/2006 13:44 (laatste wijziging 28/04/2006 13:48)
MySQL interesse
hmm ok maar dan wel zo:
<a href="index.php?p=sponsors&sid={sid}" onmouseout="{sponsorImage}.src='tpl/images/sponsors/{sponsorImage}.jpg';'" onmouseover="{sponsorImage}.src='tpl/images/sponsors/{sponsorImage2}.jpg';">
<img src="tpl/images/sponsors/{sponsorImage}.jpg" name="{sponsorImage}" width="150" height="75" border="0">
</a>
< a href= "index.php?p=sponsors&sid={sid}" onmouseout= "{sponsorImage}.src='tpl/images/sponsors/{sponsorImage}.jpg';'" onmouseover= "{sponsorImage}.src='tpl/images/sponsors/{sponsorImage2}.jpg';" >
< img src= "tpl/images/sponsors/{sponsorImage}.jpg" name= "{sponsorImage}" width= "150" height= "75" border= "0" >
</ a>
Omdat ik TemplatePower gebruik ;)
na een aantal daarme proberen is het eindelyk geljukt je had ner nog een fout in met een ' ;)
maar ghij werkt dankjulliewel slotje amg
<a href="index.php?p=sponsors&sid={sid}" onmouseout="{sponsorImage}.src='tpl/images/sponsors/{sponsorImage}.jpg';" onmouseover="{sponsorImage}.src='tpl/images/sponsors/{sponsorImage}2.jpg';">
<img src="tpl/images/sponsors/{sponsorImage}.jpg" name="{sponsorImage}" width="150" height="75" border="0"></a>
< a href= "index.php?p=sponsors&sid={sid}" onmouseout= "{sponsorImage}.src='tpl/images/sponsors/{sponsorImage}.jpg';" onmouseover= "{sponsorImage}.src='tpl/images/sponsors/{sponsorImage}2.jpg';" >
< img src= "tpl/images/sponsors/{sponsorImage}.jpg" name= "{sponsorImage}" width= "150" height= "75" border= "0" ></ a>
Gesponsorde links
Dit onderwerp is gesloten .