473,608 Members | 2,410 Online
Bytes | Software Development & Data Engineering Community
+ 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.getEle mentById("conte nt").innerHTM L = 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_effec t">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 1773
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.getEle mentById("conte nt").innerHTM L = 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_effec t">click for nice effect</a>


<a href="if_script _disabled.html" onclick="nice_e ffect();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.getEle mentById("conte nt").innerHTM L = 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_effec t">click for nice effect</a>


<a href="if_script _disabled.html" onclick="nice_e ffect();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="javascrip t/text">
function nice_image(some _html) {
document.getEle mentById("conte nt").innerHTM L = some_html;
}
</script>
<a onclick="nice_i mage([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.getEle mentById("conte nt").innerHTM L = 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
2881
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 the user selects shirts another combo box called 'size' would contain sizes in relation to shirts (ie. chest/neck size). the same would occur for trousers and hats. when the user selects an option in the garment combo box, the options available...
1
2107
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 content. From the visible frame I open a new window. This new window is created using javascript. The new window consists of two frames, both visible. During the creation of the new window a form is generated within one of the frames and...
2
2053
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 block does its own document.write of one last script block "Block C". The way this occurs is somewhat out of my control, and I need to find a way to work within this framework. This only needs to work in IE 5.5 or better. My problem is that the...
4
2134
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 "TAG#") when more than 1 number (see "VLANS") is inputed into my form. QUESTION: How do I make my dynamic form have a dynamic input box(which is created by checking the checkbox and calling the functionC1) inside it and still be able to pass the...
6
2257
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 the client from the server. I dont want to generate the entire HTML page each time from the server.'cos i need to refresh the status less than a second..
7
1485
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 database and would like to 'expand' the server controls. Possibly even recursively. Hope this makes sense, but I am guessing the answer is no. If this is something that can't be done, I am looking at creating my own markup tags and searching for...
1
5519
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 would be great , if i know how to create the dynamic HREF links like it should be getting different document based on each userid. Here is my part of jsp code for your reference: <%@ page...
23
7391
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 in an array. The application compiles but aborts without giving me any useful information. What I suspect is happening is infinite recursion. Each Directory object creates an array of Subdirectories each of which has an array of...
9
2940
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 got the core of the javascript from here: http://www.dynamicdrive.com/dynamicindex17/ajaxcontent.htm I noticed in the demo that sometimes the content takes a long
0
8067
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8010
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8501
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8483
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8157
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8349
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
5479
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
3967
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
1336
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.