|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
Stay one step ahead of the competition. Evaluate and give feedback
on some of the hottest web development tools on the market today.
Make your opinion heard! Click
Here
|
|
#1
|
|||
|
|||
|
[Javascript] Why does onclick event loads new page?
Let me explain my situation.
I've made a website for a realtor. Now on the right side of my page I made a DIV where clients can cycle through all of the appartments. So each appartment has got an image and some info with it, together with two arrows where clients can go to the previous and the next appartment info. Something like this: http://www.parkresidentie.com/img/navigator.jpg Now I've written some code too: Between head tags: Code:
<script type="text/javascript">
var teller = 0;
var planinfo = new Array("Ref: 0.A<br />Status: Te koop<br />Gelijkvloers<br />2 slaapkamers<br />103m²<br />303 850,00 €<br /><br />","Ref: 0.B<br />Status: Te koop<br />TEST",);
function inladenplan(){
document.write("<img class='plannen' src='images/plannen/" + teller + ".jpg' />");
document.write(planinfo[teller]);
document.write("<img onclick='aftellen()' class='plan_navigatie_links' src='images/pijl_links.gif' />");
document.write(planinfo[teller].substr(5,3));
document.write("<img onclick='optellen()' class='plan_navigatie_rechts' src='images/pijl_rechts.gif' />");
}
function optellen(){
teller++;
inladenplan();
}
function aftellen(){
teller--;
inladenplan();
}
</script>
Between body tags Code:
<div id="plannen">
<script type="text/javascript">
inladenplan();
</script>
</div><!--Plannen-->
So, it loads the first appartment info perfectly in the layout. But when you click the right arrow or the left one, then it loads the appartment into a blanc white page (not a new window, the page just loses his layout.) thanks in advance Last edited by mattyh88 : April 3rd, 2008 at 05:46 AM. |
|
#2
|
|||
|
|||
|
Mybe this needs to be moved at the top of the script, before function inladenplan(){
Code:
function optellen(){
teller++;
inladenplan();
}
function aftellen(){
teller--;
inladenplan();
}
__________________
[DWMX 2004]|[DWMX 8]|[DW CS3]|[MySQL]|[SQL]|[Access ]|[ASP/VBScript]|[PHP]|[XP-Pro] Global fix: "Invalid Default Script Language" Make it idiot proof and someone will make a better idiot. |
|
#3
|
|||
|
|||
|
calling document.write after the head tag will replace its content...
just document.getElementById('plannen').innerHTML= "your content here"; or go to standards using (search on the net) document.getElementById('plannen').appendChild(HTM LELEMENTobject);
__________________
my dreams are coming true... |
![]() |
| Viewing: Codewalkers Forums > Other Technologies > Client Side Things > Why does onclick event load new page? |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|
|
|
|