bluefish
Feb 17 2007, 12:48 AM
Hello, I have started to try to create a JavaScript application (or rather, AJAX, but the JavaScript is the part I'm having trouble with). I have come across a roadblock, though. I try to load an external JavaScript file by editing the innerHTML of a div tag to contain <script src="URL" type="text/javascript"> (with a real URL). The problem is that it is not loading. I have used FireBug to check the dynamic HTML status, I get the following (with code removed): CODE <html> <head/> <body> <div id="status"/> <div id="main"/> <script type="text/javascript">
</script> <div id="scripts"> <!--START DYNAMIC JAVASCRIPT--> <script src="source/main_login.js" type="text/javascript">
</script> <!--END DYNAMIC JAVASCRIPT--> </div> <script src="source/main.js" type="text/javascript">
</script> </body> </html> I have done extensive testing and am sure that main_login is not loading. When I insert the relevant code into the actual file, it works fine. Is there anything I am doing wrong and/or is there a solution? Note: This could be related to the fact that FireBug does not update the dynamically added code when I change it, but that may just be a bug. I am also having a problem with inserting HTML into a <div> tag - my tags seem to close themselves, as in the following code. It seems quite possible that the two problems are related. CODE <div id="main"> <div id="main/login"/> <form onsubmit="java script:login(this);"/> <table/> User Name: <input type="text" name="usr_name"/> Password: <input type="password" name="usr_pass"/> <input type="submit" value="Log In"/> </div> (the table, and form should encompass the whole)
Comment/Reply (w/o sign-up)
mastercomputers
Feb 17 2007, 02:10 AM
I don't really like using innerHTML and prefer using DOM methods to manipulate the documents. With innerHTML, you don't need to encode HTML entities, you can simply pass the complete string, e.g. <script type="text/javascript">... When using the DOM you must create the elements, and append the data on them. Although it requires more work, it gives better understanding to your document creation, also not all browsers support innerHTML. As with the automatic closing of each element, I can't explain that. Are you using a script you created yourself, or a script created by someone else? Cheers, MC
Comment/Reply (w/o sign-up)
bluefish
Feb 17 2007, 03:07 AM
Thanks MC, I solved the first problem by using DOM. I don't know what the original problem was, but it might have something to do with innerHTML not activating the script object. Anyways, it worked out without any real problems. As for the second problem, it was my fault for appending the lines of HTML separately, when I should have put them in a string and then put the whole string on. InnerHTML automatically closes unclosed tags when it's changed, so it could't tell that I intended to close it later.
Comment/Reply (w/o sign-up)
Similar Topics
Keywords : problems, dynamically, loading, javascript, dynamically, inserting, html
- 12 Javascript Image Galleries
(0)
Javascript Changes Aren't Working.
(6) The link is where I got it from, the code is my attempt at changing it, which has the identical
javascript, but it doesn't work. Can anyone fix it for me?
http://code.google.com/edu/client/samples/dhtmltest.html CODE example body {font: 14px
arial; color: #000066;} #mytext {position: absolute; top: 100px; left: 400px; font: 24px arial;
font-weight: 900; } var texttop = 100; var textleft = 400; function vanish(flag) { var myObj
= new getObj('myText'); myObj.style.visibility = (flag) ? 'hidden' :
'visible' } function m....
Javascript Help Needed : Alert(z) Works Fine But Document.write Not
please (2) hi all, I am facing problem in my javascript, any kind of help would be apreciated CODE
function basicFiles(){ //var Z = ""; for (i = 0; i var x =
document.Form.regionlist.options .value; var y = document.Form.regionlist.options
.text; var Z = "regions" + " " + " = " + y + ", "; alert(Z);
} } this works well but the following returns only errors CODE
function basicFiles(){ //var Z = ""; for (i = 0; i var x =
document.Form.....
Focus() And Select() Problems With Firefox
(2) Hi guys, I am new to javascript and am currently learning it with the book Wrox Beginning
Javascript 3rd ed. I have just encountered a problem that I am not able to figure out. Could you
please help me out..... The problem is that select() and focus() are not working in FF2.0 but works
in IE7. This is what the code is supposed to do: 1. I enter a age 2. If I enter non numerical data
and then I tab out of the text area 3. An alert box pops up and tells me to correct the age. 4. On
hitting ok it goes back to the age field. But in FF its going to the next tag(the submi....
Ajax Loading Bar
How do you do it? (7) Hi, I've seen some sites around that use ajax alot, for loading pages, images etc. And
I've noticed that, instead of just showing a picture or text while loading, they have a loading
bar. How do you do that? Is there any way of finding out how much of something in ajax has loaded,
and use a loading bar to show it? ....
Fun With Javascript And Forms
Lets have some fun with javascript! (2) I will post here every week with new and exciting things to do in javascript! After i finish 10 of
them , ill do Ajax(real-time) - 1.Alerting and documenting Forms Ever seen those dynamic sites
where if you hove your mouse or type something bad..etc , it popups up or dynamically gets written
onto the page? Well i am here to teach or rather help with all that stuff! Step 1:Get notepad out
and make a form CODE Text displays here: Step 2: Add the javascript Bit CODE
function onKeyDown() { document.GetElementById('r').innerHTML=document.....
Include Function For Javascript
(7) I've been working on an include function for javascript. It works just fine in Firefox and IE,
but for some reason, it doesn't result in the loading of the scripts for Safari. The code is as
follows: CODE function include(url) { // Include Guard var scripts =
document.getElementsByTagName("script"); for (var index = 0; index if (scripts.src == url) {
return; } } // Inclusion var head =
document.getElementsByTagName("head").item(0); var script =
head.appendChild(document.createElement("script")); script.type = "text/javascrip....
Problems Dynamically Adding A Table With Dom
(4) I'm writing a search function to search a MySQL database I have. The search uses AJAX with a
php server to search the database and generate a result. The result is passed back as a DOM object
to the javascript, which then parses the result into an xhtml table. I then add the table to my
page. This works just fine under Firefox. However, under IE (version 7, so I assume others as
well), the table doesn't display. I used the IE Developer Toolbar to look at the DOM, and the
table has been successfully added to the DOM, but it isn't showing up. Interesting....
Problem With Javascript Alert();
(9) Hi Everyone, i just need to know that this javascript code is formatted correctly: (A piece of
code that it's written BESIDE an HTML code.) CODE My body contents |||Always keeps
telling me that this was incorrect. ....
Problem With Form Elements
How to Add/Remove form elements created dynamically (3) Hi everybody, i have a problem with a form where i want to add or remove elements from it
dynamically, i'm working on an invoice form, like the following: CODE Nro.
Date # product Quantity Price Total
In this form the values are obtained from a
database (edit mode) or are entered by the user (add mode), of course there is a case tha....
Activex In Html
anyone know how to use ActiveX control in WebApp? (6) I'm writing a web application for language learning and I'd like to use the Speech API from
Microsoft for speech recognition. Therefore, I need to embed an ActiveX control to the web page
(html file). The questions are: 1. How to embed this ActiveX control to the web page, I don't
know the class id of that control. For a RealPlayer, I would use and in this case, i need the
value for classid . 2. In case the user (client) doesn't have that activeX control, how to
have it downloaded automatically (with permission)? 3. How to handle the event....
Javascript: How Do I Create Embedded Pop-up Windows?
(7) The post title summarises my query - how do I create pop-up windows that are embedded inside a page?
Broadly, there are two kinds of JavaScript pop-ups.. one is that ultra annoying one, which pops
out a new instance of a browser window and displays something there (usually an ad) - made infamous
by all the warez and porn sites. Second one, which has come to be quite well-known of late is the
kind you see in recent versions of WordPress (in the Visual Editor) as well as LightBox based
galleries. Here a small window (or rather a div) pops-up embedded in the middle of t....
Javascript Question
Vertical Scroll Box (6) Alright well I've been working and modifying this template for about a year now I think and
I've started used JavaScript in it (bad to use templates I know, but I can't design them
x_x). So I'm trying to put a vertical scroll box in my side events panel to save space, but it
won't recognize the script. It takes the horizontal one I have as you can see if you look at
the site, but not the vertical. Actually it won't take anything in that little panel. So my
question really is, what could cause a javascript code to not work on a certain webpage ....
Add Text To Textarea
I suppose it uses DOM and JavaScript?? (6) I am working on a web "application" thing that allows you to click a button to add text to a
textarea. Similar to this forum when you click the BOLD button and it puts in {b}{/b} with the
square brackets. I want a similar function like that. Also, I want it to add wherever the cursor is,
not at the end. And after adding the thing, the cursor should be in between the tag or whatever that
was added. All the extra stuff are extra priorities. For now I would like to get something that
inserts text on click. The thing I came up with is: HTML html > head > text/javasc....
I Need Help With Javascript.
help plz (7) Well, I want to learn to code in JavaScript, but when I try to view the page in Firefox, it
dosen't work. Can anyone tell me why its not working? Do i need to use a different browser?....
JavaScript Frames & Querystring
(4) Hi, I actually want to create a HTML page which has the capablity of reading a QueryString
(x.html?querystring=test) and then using a hidden frame pass on the data to an ASP Script on another
server. For obtaining the QueryString i use the following:- CODE function
getQueryVariable(variable) { var query = window.location.search.substring(1); var vars =
query.split("&"); for (var i=0;i var pair = vars .split("="); if (pair == variable) {
return pair ; } } } alert( getQueryVariable("QueryString") ); Now my
problem is to cre....
Vertical Marquee Using JavaScript
by The JavaScript Source (1) Hi, i find this script and hope that will be useful for somebody. Text scrolls from bottom to top,
pauses, then scrolls up and out of view. A link can be added, opening in a new window. Configuration
is simple. First copy the following code in a new file and name it vertical.js CODE /* This
script and many more are available free online at The JavaScript Source ::
http://javascript.internet.com Created by: Mike Hudson :: http://www.afrozeus.com */ /* To change
the values in the setupLinks function below. You will notice there are two arrays for each of Titles
and L....
Create And Import JavaScript Modules For A Large Script
(2) I have one main script which defines an object. I then have several other script files that define
functions for that object. I have tried using the following setup to import the functions: HTML
code snippet: Javascript code snippet: import Object.functionName; This works fine for
Mozilla Firefox, but causes an error in Internet Explorer which causes the object to be undefined.
I would like to know how better to import the functions into the main javascript (preferably without
needing to add the module script to the html file) that works in both Firefox a....
Ever Needs To Find Out A Table Height Or With With JavaScript
Well stop looking, here is the answer (CSS and JS) (2) Welcome everybody to this litle tutorial. by v.DragonEyE.n09 Introduction: Using
javascript you can find the height and width of a table, cell, div, image, etc.. the more simple way
is to ask for this... QUOTE id= "myElement" border= "0" cellpadding=
"0" cellspacing= "0" style= " height : 300px ; width
: 450px ; " > some
fake text and images for the example some fak....
JavaScript: Hide And Show Any Element With CSS
From the simple way to the more advanced way (Javascript & CSS) (9) Welcome everyone, this is my first post. The first thing you need to know is... CSS
has two special attributes, the first one is " display " and the second is " visibility ". The
difference between these two goes like this. " display ": has many properties or values, but the
ones we need are "none" and "block". "none" is like a hide value, and "block" is like show. If you
use the "none" value you will totally hide what ever html tag you have applied this css style. If
you use "block" you will see the html tag and it's content. very simple. " visibi....
Javascript: Browser Detection Script
Detect your visitors browser (2) If you want to detect your visitors browser, sebd them a message and redirect them use this script:
CODE var browserName=navigator.appName; if (browserName=="Netscape") { alert("Hi Netscape
user!") window.location = "netscape.html" } else { if (browserName=="Microsoft Internet
Explorer") { alert("Hi Microsoft Internet Exlorer User!"); window.location = "MIE.html" }
else { alert("What are you browsing with?"); window.location = "unkown.html" } } //-->
....
JavaScript: Simple Dropdown Menu
Simple Dropdown Menu (5) This simple dropdown menu is flexible enough to be used in various ways. It can be placed and
modified in the webpage as is.....
Javascript: Simple Slidedown Menu
Simple Slidedown Menu (2) This is a simple slidedown from the top menu. It can be placed on the Webpage as is. To modify it
to a slideout menu, simply change the style and postion of the menu.....
Dynamically Change The Background Image On Mouse Effects!
easy code to dynamically change the background image (4) stun ur visitor with a new bg image on every mouse click of his! easy code to dynamically change
the background image. Copied from http://www.scriptworm.com/scriptengine/visit.php?id=30296
QUOTE control the background image using the links on your site. control the color using
onMouseOver, onMouseOut, onClick, and a combination of all of them. place the code below between
the and tags within the HTML page where you want the link to appear. edit the link text provided to
point at the page you would like to open. Option 1: use this to change the background ....
Javascript: Text To Texbox And Back To Text
(3) i need some help i want to create a thing where when some one double clicks a certain text it
changes into a texbox where they can edit the text and the they double click and it changes into the
test they just typed in. I have found this function in javascript that does some of it but i needs
to be simplified CODE "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> Span to
Text Box - Demo - DOM /* © John Davenport Scheuer */ function exchange(el){ var
nodeI=el.parentNode, inputC=document.createElement('input'), text=el.innerHTML; el.style.f....
Best Way To Learn Javascript
I would very much like to know. (11) Well, I know HTML, I know CSS, so the next step is learning Javascript. I have heard that it is sort
of an easier way to do things than PHP, though I would very much like to learn PHP as well. So, I
thought that if I learnt Javascript, I might find it easier to learn PHP when I get to that point.
The problem though is actually finding out the best way to learn Javascript. I have been to
websites and things, but every time I read through the tutorials and articles and things, I
didn't learn anything. It when in one ear and out the other, you could say. So, that is wh....
Javascript: Disable Mouse Right-click In Browser
(17) just copy and paste this on to your html site in the head tag CODE /* */ var message="Hey
YOU!\nStop Stealing my pictures or\nFACE THE PUNISHMENT!" function click(e) { if (document.all)
{ if (event.button == 2) { alert(message); return false; } } if (document.layers) { if (e.which ==
3) { alert(message); return false; } } } if (document.layers) {
document.captureEvents(Event.MOUSEDOWN); } document.onmousedown=click; // --> ....
javascript vs java
(12) in my opinion javascript is better then java becasue java requires more programing experecense then
javascript and i think to that javascript is more reliable then java in some ways....
How To Create A Popup Window With Javascript?
(19) Please help me! I want to in popup massage suggest to visitors of my site to make my site their home
page . Please note that I have some script code that visitors most click on a text to make my site
their home page . Every one that can help me please send an email to soleimanian@noavar.com....
Getting Screen Resolution using Javascript.
(10) Is it possible to get the screen resolution of the users moniter using only javascript. No other
external stuff, just pure javascript. I guess most of the people using JAVA for this. I also got
some scripts regarding this which used SCREEN.WIDTH function or something, but they did not seem to
work out. Any possible solutions. BTW, is it possible to get the resolution using PHP ( I guess it
is not ) .......
Looking for problems, dynamically, loading, javascript, dynamically, inserting, html
|
See Also,
*SIMILAR VIDEOS*
Searching Video's for problems, dynamically, loading, javascript, dynamically, inserting, html
|
advertisement
|
|