SunQuest
           Client Side Things
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Codewalkers ForumsOther TechnologiesClient Side Things

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Codewalkers Forums Sponsor:
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  
Old April 3rd, 2008, 04:59 AM
mattyh88 mattyh88 is offline
Registered User
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2008
Location: Belgium
Posts: 1 mattyh88 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 40 m 11 sec
Reputation Power: 0
[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.

Reply With Quote
  #2  
Old April 30th, 2008, 01:06 AM
student101 student101 is offline
Contributing User
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Nov 2007
Posts: 98 student101 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 7 h 27 m 47 sec
Reputation Power: 1
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.

Reply With Quote
  #3  
Old May 21st, 2008, 10:55 AM
DanDaBeginner DanDaBeginner is offline
Contributing User
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Location: Philippines
Posts: 331 DanDaBeginner User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 Day 10 h 8 m 47 sec
Reputation Power: 2
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...

Reply With Quote
Reply

Viewing: Codewalkers ForumsOther TechnologiesClient Side Things > Why does onclick event load new page?


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 5 hosted by Hostway