473,815 Members | 3,461 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Javascript Reload external Files

2 New Member
I am very new using javascript and I faced a problem that with my expertise I cannot solve.
I wrote a small html file that handle a vertical menu. I wrote a function to show the menu correctly using javascript. The contents of the menu are dynamic changed. In my project I have two javascript file: the first has all the functions to handle the menu and the second has just a JSON array with the information for the menu.
Example:
Expand|Select|Wrap|Line Numbers
  1. var mv =
  2. [
  3. ["1","Fórum"],
  4. ["11","Aberto","http://labadm.metodista.br/MP.exe/mp?si=49179&w=3&p1=1&p2=172"],
  5. ["12","Pessoal","http://labadm.metodista.br/MP.exe/mp?si=49179&w=3&p1=1&p2=173"],
  6. ["2","Consulta"],
  7. ["21","Enviar E-mail","mailto:monocomltd.1305@macpenn.com.br"],
  8. ["3","Caso"],
  9. ["4","Sair do experimento"]
  10. ];
  11.  
(the language here is Portuguese)

I load the two js files in my html in the static way (the first with the functions and the second with the data):
[HTML]<head>
.
.
.
<script type="text/javascript" src="ms_js/mp_mm.js"></script>
<script type="text/javascript" src="ms_js/mp_mm_d.js"></script>
</head>
[/HTML]
I also run the menu function in the body section:
[HTML]<body onload="menu(mv ,0),menu(mh,1)" >[/HTML]

I wanted to change the menu information dynamically changing only the js data file as the user click in a link (this is a test project only), instead of running all page again, for this action I am using two function I could found here http://www.javascriptkit.com/javatut...criptcss.shtml.

The main function use parentNode.repl aceChild to replace the mp_mm_d.js file (that has only a JSON var inside) when the user click the link:

[HTML]<a href="javascrip t:replacejscssf ile('ms_js/mp_mm_d.js', 'ms_js/mp_mm_d1.js', 'js')">Troca Menu</a>
[/HTML]
To run the menu function I include in the main function above a call to my menu constructor: menu(mv,0)

The mp_mm_d1.js is identical the older file mp_mm_d.js the the var mv contents (the name of the variable is the same but the contents).

Everything works fine, I mean: the mp_mm_d.js file was replaced by mp_mm_d1.js file and I got any error in the process, but the variable contents include in the mp_mm_d1.js was not loaded or not changed in the process.
I tried a lot of things to make this running well without success.
It seems that the browser do not reload the replaced file changing the variable as requested, or I am misunderstandin g the whole process.
Is there a way to reload the js file in order to use the new variable information?

Thank you for reading this and hope to get an answer soon.

Wagner
Nov 25 '07 #1
3 3100
acoder
16,027 Recognized Expert Moderator MVP
Welcome to TSDN!

Have you inspected the DOM after replacing that it has indeed been replaced?
Nov 26 '07 #2
wbazarin
2 New Member
Dear friends, I had already solved the problem! The key was to check the complete reload before continuing the process. Thanks all!
Nov 27 '07 #3
acoder
16,027 Recognized Expert Moderator MVP
Glad you got it working. Post again if you have another question.
Nov 27 '07 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

3
2032
by: annon | last post by:
I've noticed that some problems come up frequently that are of importance in writing web pages, because they're pretty fundamental points. For general reference, here are some collected solutions. 1. Opens a new Window at maximum size: window.moveTo(0,0,screenX=0,screenY=0) window.resizeTo(screen.availWidth+2,screen.availHeight+6)
5
5216
by: joaopedrogoncalves | last post by:
Hi, I want to load an external javascript file, get its results and stick them inside a <div> block. I also want to do this in several places on a web page. This way the browser doesn't have to wait for the external resource to load to show up the page, thus giving a perceiving faster load time for the user.
2
3625
by: robert.waters | last post by:
Hello, I am dynamically editing the contents of a page and using document.write() to reload the new, edited content. However, on the new page, any calls to functions located in external .js files (fyi: same domain) fail with 'object expected' (IE6). If I subsequently reload the page, everything works. Also, if I inline this code, everything works. Here is an example: (called from body onload event) (This just rewrites the page with...
3
1403
by: I.g.o.r. | last post by:
Hello! I run into a very anoying problem in asp.net 2.0. I have external JScript file included in some aspx through <script> tag; In my solution .js file is placed in custom folder named skripta. Everything is ok when I add new .js file containing some code. But when I add some new functions to .js (everything doing through visual studio 2005 editor) they seam to be invisible for the aspx page in which the external script is referenced....
4
1586
by: James Pemberton | last post by:
I have recently created a ASP site utilizing Master Pages and all works fine until I want to proces my javascripts. Just to let you know, most of cliewnt side scripting is new to me. But anyway, I can retrieve and updat ethe value a textbox on the page by using the document.getElementById('Goals_Main_tbProduct0').value
19
19279
by: Tony | last post by:
I'm working on project that plays movies using Windows Media Player and I'm controlling everything with JavaScript. Per the client I only need to support IE 6 or greater which happens to make things a bit easier. What I need to do is create a playlist and play it using JavaScript. I keep on getting close but not close enough to play the dang files. Has anyone done this before and can shed some light on what worked for them?
4
2021
by: Neo Geshel | last post by:
I am experiencing a collision between two scripts, but I cannot find where it is. I am hoping that someone here can help me. I have two external JS files that I call into each web page. One provides me with a standards-compliant way of creating pop-up windows by simply adding a rel="external" to each anchor. The other allows me to have toggled definition lists. When the popupwin.js file is by itself, all anchors with rel="external"...
7
4117
by: Hrvoje Vencl | last post by:
Hi everyone, is there a way to reload all external scripts each 60 sec? By external I mean on <script src="status.php" type="text/javascript"></script> so lets say that I have several includes of scripts in a HTML page and is there a way to reload it each 60 sec? I know I can do this by AJAX, but can it be done this way?
2
1905
by: nitinpatel1117 | last post by:
Hi, I wanted to know if there was a way to reload an external javscript file. Basially, what i have is a customised scrollbar, this scroll bar is created in javascript. and the source file is included in the header. The script works perfectly well, and displays a scoll bar when the content overflows the specified height of its holder div. the scoll bar is not displayed when the content fits inside the containing div.
0
9736
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
10672
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
10408
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
10428
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
9226
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6897
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
5570
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...
1
4359
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 we have to send another system
2
3888
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.