Connecting Tech Pros Worldwide Forums | Help | Site Map

calling html file from javascript

Member
 
Join Date: Oct 2007
Posts: 82
#1: Mar 11 '08
Hi,

Is there any way to call html file from a javascript.

What I want to do is as following:

1) send information to sever and checkit by using Javascript.
2) if everything is OK. call another html file inside the same javascript.

How it can be done.

gits's Avatar
Moderator
 
Join Date: May 2007
Location: Munich, Germany
Posts: 4,136
#2: Mar 12 '08

re: calling html file from javascript


hi ...

please explain a little bit more what you mean with:

' ... call another html file inside the same javascript ... '

kind regards
hsriat's Avatar
Expert
 
Join Date: Jan 2008
Location: Bath, UK
Posts: 1,609
#3: Mar 12 '08

re: calling html file from javascript


Quote:

Originally Posted by raknin

Hi,

Is there any way to call html file from a javascript.

What I want to do is as following:

1) send information to sever and checkit by using Javascript.
2) if everything is OK. call another html file inside the same javascript.

How it can be done.

Is it something like Google's login?
Familiar Sight
 
Join Date: Oct 2006
Posts: 141
#4: Mar 12 '08

re: calling html file from javascript


Hi ,

u can call another html file by using window.navigate("htmlfile.html") in javascript


Quote:

Originally Posted by raknin

Hi,

Is there any way to call html file from a javascript.

What I want to do is as following:

1) send information to sever and checkit by using Javascript.
2) if everything is OK. call another html file inside the same javascript.

How it can be done.

gits's Avatar
Moderator
 
Join Date: May 2007
Location: Munich, Germany
Posts: 4,136
#5: Mar 12 '08

re: calling html file from javascript


Quote:

Originally Posted by vee10

Hi ,

u can call another html file by using window.navigate("htmlfile.html") in javascript

that is certainly IE only and so it is not standards-compliant - i woudn't recommend that method unless you are sure to code for IE only (may be an intranet-solution) ... but to solve the problem we first have to know exactly what the requirement is ...

kind regards
Member
 
Join Date: Oct 2007
Posts: 82
#6: Mar 13 '08

re: calling html file from javascript


The situation is:

I want to move from one html file to another and stay in the same window.

The process that I am going through is as following:

I am submitting the result of the page throgh javascript to the server using AJAX and PHP.
if everthing is fine I want to load a second html page instead of the current one.

I think this is clear
gits's Avatar
Moderator
 
Join Date: May 2007
Location: Munich, Germany
Posts: 4,136
#7: Mar 13 '08

re: calling html file from javascript


then let your server send an ok or an url and set the location.href of the window ... alternativly you could send the html and replace the innerHTML of the documents body ...

kind regards
Member
 
Join Date: Oct 2007
Posts: 82
#8: Mar 13 '08

re: calling html file from javascript


Quote:

Originally Posted by gits

then let your server send an ok or an url and set the location.href of the window ... alternativly you could send the html and replace the innerHTML of the documents body ...

kind regards

Unfortunately the location.href is not working maybe I don't use it correctly I am using window.location.("http://www.xx.com/xxx.htm") but nothing happen I not taken to the new page I check it on IE and FF.

I check it with the document body and it doesn't work for me.

Thanks anyway
gits's Avatar
Moderator
 
Join Date: May 2007
Location: Munich, Germany
Posts: 4,136
#9: Mar 13 '08

re: calling html file from javascript


try this:

Expand|Select|Wrap|Line Numbers
  1. window.location.href = "http://www.xx.com/xxx.htm";
kind regards

ps: note that this loads a new page and breaks out of the 'ajax-paradigm' to reload content in the background ...
Member
 
Join Date: Oct 2007
Posts: 82
#10: Mar 14 '08

re: calling html file from javascript


Quote:

Originally Posted by gits

try this:

Expand|Select|Wrap|Line Numbers
  1. window.location.href = "http://www.xx.com/xxx.htm";
kind regards

ps: note that this loads a new page and breaks out of the 'ajax-paradigm' to reload content in the background ...

Gits,
Thanks this is exactly what I was looking for I will try it and let you know
gits's Avatar
Moderator
 
Join Date: May 2007
Location: Munich, Germany
Posts: 4,136
#11: Mar 14 '08

re: calling html file from javascript


no problem :) ... post back when there are problems with it ...

kind regards
Member
 
Join Date: Oct 2007
Posts: 82
#12: Mar 15 '08

re: calling html file from javascript


Thanks gits it is working perfect.
Reply