By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,970 Members | 1,668 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,970 IT Pros & Developers. It's quick & easy.

script on page

P: n/a
I load some page using XMLHttpRequest. It has some java script on it. I add
this page (using innerHtml) to another but then the java script doesn't run.

The main page has

<script>
function go()
{
getElementById("replaceContent").innerHtml=httpReq .text;
}
</script>

<div id="replaceContent"> </div>

this is the page which I load in the background
<script>
alert("form request");
</script>

How to make the script from added innerHtml to run.

Patryk
Aug 29 '05 #1
Share this Question
Share on Google+
5 Replies


P: n/a
alu

"P4tryk" <p4****@patryk.pl> wrote
<script>
function go()
{
getElementById("replaceContent").innerHtml=httpReq .text;
}
</script> How to make the script from added innerHtml to run.

innerHTML is case sensitive, and getElementById is a method of the document
object.

The correct syntax would be:

document.getElementById("replaceContent").innerHTM L=httpReq.text;

-alu
Aug 29 '05 #2

P: n/a
ASM
P4tryk wrote:
I load some page using XMLHttpRequest. It has some java script on it. I add
this page (using innerHtml) to another but then the java script doesn't run.
innerHTML

and not

innerHtml
<script>
function go()
{
getElementById("replaceContent").innerHtml=httpReq .text;
}
</script>


--
Stephane Moriaux et son [moins] vieux Mac
Aug 30 '05 #3

P: n/a
Użytkownik "alu" <no**@none.com> napisał w wiadomości
news:jh*******************@news20.bellglobal.com.. .
innerHTML is case sensitive, and getElementById is a method of the
document
object.


ok, but how to make the script from the loaded page to run.
Patryk
Aug 30 '05 #4

P: n/a
alu
> "P4tryk" <p4****@patryk.pl> wrote

<script>
function go()
{
getElementById("replaceContent").innerHtml=httpReq .text;
}
</script>

How to make the script from added innerHtml to run.


_______________________________________________
innerHTML is case sensitive, and getElementById is a
method of the document object.
The correct syntax would be: document.getElementById("replaceContent").innerHTM L=httpReq.text;
-alu

_______________________________________________
ok, but how to make the script from the loaded page to run.
Patryk

_______________________________________________

You are using XMLHttpRequest to load an alert? You may be trying to kill a
mosquito with a sledgehammer here....
I can't say I understand the structure of your page(s), or the purpose of
loading the alert in the background(?).
You are asking how to make the script from the loaded page run - all I can
think of is that you are asking how to call the function itself, perhaps?
If this is the case, just call the function as below:

<script>
function go()
{
document.getElementById("replaceContent").innerHTM L=httpReq.text;
}
</script>

<div id="replaceContent"> </div>
<script>
alert("form request");
</script>

// somewhere in an appropriate place then, you would actually call the
function...

go();
Hope this solves the problem, if not, please explain clearly what you are
trying to achieve.
-alu
Aug 30 '05 #5

P: n/a
Użytkownik "alu" <no**@none.com> napisał w wiadomości
news:sa*******************@news20.bellglobal.com.. .
Hope this solves the problem, if not, please explain clearly what you are
trying to achieve.


This was an simple example I don't want to load alert from XMLHttpRequest.

I use telerik menu control, you can build nice context menus for .net.
The problem is that I can only build the menu on server side, but I need to
show different context menu every time the user clicks an element and I
can't refresh the page.
The scenario is
-user cliks
-xmlReq to server
-the server builds menu
-I attach the menu from using innerHtml

The only problem is that I need to run js from the laded page. The js is
between <scritp> </script> there is no function I can call. The js is needed
to attach the events and do some other things that I dont't know and it's
different every time.

Patryk



Aug 31 '05 #6

This discussion thread is closed

Replies have been disabled for this discussion.