473,465 Members | 1,651 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

dynamic content does not process JAVASCRIPT. need help!

Re,

SCENARIO: User clicks a link and a javascript function creates dynamic
content in <div id="content"></div> using:

document.getElementById("content").innerHTML = something [something is
a variable that holds a chuck of HTML code]

In the page's header I load a javascript that does nice effect to
pictures. In HTML code I have the following element that contains
referect for that said javascript:

<a href="a.jpg" rel="nice_effect">click for nice effect</a>

PROBLEM: Everything is properly displayed, however, javascript is not
activated when the link is pressed.

Now, I can use eval(something) to process a simple request such as
'alert("hello")', but how do I re-eval ALL javascripts that are
included in the page's header OR that are included in the content that
I am creating (i.e. in addition to a bunch of <a> elements, I will
include a <script> element)???

This following page shows a function that goes through the whole HTML
and re-declares all functions that are found in <script></script>
elements: http://www.modernmethod.com/sajax/fo...opic.php?t=205

It appears to be the solution that I need, however, the code doesn't
seem to work (or perhaps I am not using it correctly) and the author
cannot be contacted.

Are there any knowledgeable people in this group who could please help
me? I need the javascript to work with elements that are dynamically
included in the page AFTER it is loaded.

Thank you!!!!!!!

Feb 19 '06 #1
4 1763
VK

na************@msn.com wrote:
Re,

SCENARIO: User clicks a link and a javascript function creates dynamic
content in <div id="content"></div> using:

document.getElementById("content").innerHTML = something [something is
a variable that holds a chuck of HTML code]

In the page's header I load a javascript that does nice effect to
pictures. In HTML code I have the following element that contains
referect for that said javascript:

<a href="a.jpg" rel="nice_effect">click for nice effect</a>


<a href="if_script_disabled.html" onclick="nice_effect();return
false;">
Click here for nice effect
</a>

Feb 19 '06 #2
VK,

This does not solve my problem nor is how the script activated. The
problem is that dynamically included content is not really included
when you view the source, hence the script (in the header) does not
process it. Nor are processed any JS functions that are included unless
I use eval(function) when or after I include the content.

VK wrote:
na************@msn.com wrote:
Re,

SCENARIO: User clicks a link and a javascript function creates dynamic
content in <div id="content"></div> using:

document.getElementById("content").innerHTML = something [something is
a variable that holds a chuck of HTML code]

In the page's header I load a javascript that does nice effect to
pictures. In HTML code I have the following element that contains
referect for that said javascript:

<a href="a.jpg" rel="nice_effect">click for nice effect</a>


<a href="if_script_disabled.html" onclick="nice_effect();return
false;">
Click here for nice effect
</a>


Feb 19 '06 #3
Hello,

It looks like you need to create a function, and then call the function
with the onclick() handler, similar to the code VK posted. Something
like this:

<script type="javascript/text">
function nice_image(some_html) {
document.getElementById("content").innerHTML = some_html;
}
</script>
<a onclick="nice_image([Add HTML here]);">Nice effect</a>

It seems like that should work, no matter where the javascript is
located.

Chris S.
Implied By Design LLC.
http://www.impliedbydesign.com
Free Web Design Tools
http://www.impliedbydesign.com/free-...e-scripts.html

Feb 21 '06 #4
na************@msn.com wrote:
document.getElementById("content").innerHTML = something [something is
a variable that holds a chuck of HTML code]
[...]
Now, I can use eval(something) to process a simple request such as
'alert("hello")', but how do I re-eval ALL javascripts that are
included in the page's header
[...]
This following page shows a function that goes through the whole HTML
and re-declares all functions that are found in <script></script>
elements: http://www.modernmethod.com/sajax/fo...opic.php?t=205


The best thing on this case is to not load the html with javascript
together, which looks strange in my opinion.

I took a look on your link, it's bad written, the regexp is bad and
there are global variables (a lot). It just captures functions and
redeclare them in a bad way (using eval, which isn't needed on this case).

To solve your problem, just collect all the scripts and make a big eval,
just take care to ignore inline script tags (I mean for ex:
alert('<script></script>'), which would break your code deppending of
your approach) and check if the <script> has a src property =]
--
Jonas Raoni Soares Silva
http://www.jsfromhell.com
Feb 28 '06 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

13
by: mr_burns | last post by:
hi, is it possible to change the contents of a combo box when the contents of another are changed. for example, if i had a combo box called garments containing shirts, trousers and hats, when...
1
by: GEvans | last post by:
Hi, I have a HTML page consisting of two frames, one visible and one hidden. The hidden frame contains javascript variables holding session information. The visible frame contains interactive...
2
by: thinkfr33ly | last post by:
I have a page that inserts a block of javascript dynamically into the page "Test.html". The inserted block, "Block A", then does a document.write of another script block "Block B". This script...
4
by: pizzy | last post by:
INTRO: I tried to clean it up for easy reading. I hope I didn't make any mistakes. PROBLEM: WOW, this is some crazy sh!t. I can't get my checkbox (see "TAGSELECTED") to print my textboxes (see...
6
by: Vanitha | last post by:
Hi All, I am developing a Web based application for an embedded target, using BOA webserver. I need to return some values to the HTML client. I am using CGI-C to extract the values sent by...
7
by: Andrew Robinson | last post by:
Given HTML text (likely from SQL), is there any method that could be employed to render server and/or custom controls that are contained inside of that text? I would be loading content from a...
1
by: nsvmani | last post by:
Hi, i am trying to get the FileOpen dialogue window as soon as clicked href link I am using IE6 with ActiveX enabled. Just need to get the File Open dialogue window when i click on the HREF links.It...
23
by: sandy | last post by:
I need (okay, I want) to make a dynamic array of my class 'Directory', within my class Directory (Can you already smell disaster?) Each Directory can have subdirectories so I thought to put these...
9
by: pbd22 | last post by:
Hi. This is just a disaster management question. I am using XMLHTTP for the dynamic loading of content in a very crucial area of my web site. Same as an IFrame, but using XMLHTTP and a DIV. I...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.