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

JS external file loaded in bad way

P: n/a
hello wverybody...
i've got a terrible matter with JS

my browsers (either IE and NN) load the external scripts uncorrectly...they
load the files from the half part of them and not from the beginning, so my
scripts don't work giving syntax errors.

can you give me a solution?
Jul 23 '05 #1
Share this Question
Share on Google+
10 Replies


P: n/a
"Pasquale" <we*******@retailcenter.it> wrote in message
news:LE**********************@news4.tin.it...
hello wverybody...
i've got a terrible matter with JS

my browsers (either IE and NN) load the external scripts uncorrectly...they load the files from the half part of them and not from the beginning, so my scripts don't work giving syntax errors.

can you give me a solution?

How many different groups are you going to post this at!
Jul 23 '05 #2

P: n/a
Pasquale wrote:
hello wverybody...
i've got a terrible matter with JS

my browsers (either IE and NN) load the external scripts uncorrectly...they
load the files from the half part of them and not from the beginning, so my
scripts don't work giving syntax errors.

can you give me a solution?


Fix your browsers, or, post more detail. Perhaps a sample page that
shows the behavior.

--
Randy
comp.lang.javascript FAQ - http://jibbering.com/faq
Jul 23 '05 #3

P: n/a
i show here the translation of my problem from italian to english made by
google language tool ( i hope it will be not so bad).then there are the
files : accesso.php is a simple example of the strange behaviour and
articoli is something more complex (it has 2 external files)

the project one that I am developing has many functions JS that I have put
in external files. until a month ago they worked well... i stopped
developing for a month for personal reasons and now that I have resumed my
project I have noticed one matter... all the scripts come load evil from
the browsers i use (NN and MSIE), in the sense that, as the NN Javascript
console tells me, the files js with the functions come loaded incomplete,
that is do not from the beginning but from a particular point approximately
to the half of the file. that cause the loss of functions and obviously
syntax errors...

in the past month i installed some windows updates,
i use apache 2,0,52 on win xp sp2

help me... is my thesis of bachelor! thaks a lot

"Pasquale" <we*******@retailcenter.it> ha scritto nel messaggio
news:LE**********************@news4.tin.it...
hello wverybody...
i've got a terrible matter with JS

my browsers (either IE and NN) load the external scripts
uncorrectly...they load the files from the half part of them and not from
the beginning, so my scripts don't work giving syntax errors.

can you give me a solution?

Jul 23 '05 #4

P: n/a
Pasquale wrote:
i show here the translation of my problem from italian to english made by
google language tool ( i hope it will be not so bad).then there are the
files : accesso.php is a simple example of the strange behaviour and
articoli is something more complex (it has 2 external files)
Can't see the files. My news provider doesn't support files. Post as
text inside the message and try to make sure it's as simple an example
as possible.

the project one that I am developing has many functions JS that I have put
in external files. until a month ago they worked well... i stopped
developing for a month for personal reasons and now that I have resumed my
project I have noticed one matter... all the scripts come load evil from
the browsers i use (NN and MSIE), in the sense that, as the NN Javascript
console tells me, the files js with the functions come loaded incomplete,
that is do not from the beginning but from a particular point approximately
to the half of the file. that cause the loss of functions and obviously
syntax errors...
It's not a great translation, but I get the jist.
in the past month i installed some windows updates,
i use apache 2,0,52 on win xp sp2

help me... is my thesis of bachelor! thaks a lot

"Pasquale" <we*******@retailcenter.it> ha scritto nel messaggio
news:LE**********************@news4.tin.it...
hello wverybody...
i've got a terrible matter with JS

my browsers (either IE and NN) load the external scripts
uncorrectly...they load the files from the half part of them and not from
the beginning, so my scripts don't work giving syntax errors.

can you give me a solution?


Jul 23 '05 #5

P: n/a
this is the simplier example :

php page

<head>
<link rel="stylesheet" type="text/css" href="stile.css">
<script src="scripts.js" type="text/javascript">
</script>

</head>

<body>
<?php
$login=$_POST['identita'];
$q="select password,nome from utenti where login='$login'";
$host="localhost";
$connessione=mysql_connect($host,null,null);
mysql_select_db('magazzino');
$risultato=mysql_query($q);
$riga=mysql_fetch_array($risultato,MYSQL_BOTH);
$pw=$riga[0];
$nome=$riga[1];
$tipo=$riga[2];
if ($pw!=$_POST['password']) {
echo "<h2>Accesso non autorizzato a MAST</h2> ";
echo "<h4>Controllare la password immessa per identificare l'utente</h4>";
echo "<center><img src=img/logo.bmp width=300 height=100>";
echo "<br><a href=index.html>Torna all'accesso</a>";
exit();
}
mysql_free_result($risultato);
mysql_close($connessione);
?>
<p>Redirezione alla schermata iniziale in corso...</p>
<form method=POST name=formaccesso action=welcome.php>
<input type=hidden name=nome value="<?php echo $nome ; ?>">
<input type=hidden name=tipo value="<?php echo $tipo ; ?>">
</form>
<script type=text/javascript>
js_home();
</script>
</body>

and this is the javascript file

//SCRIPTS UTILIZZATI

function js_2190_variati (){

form1.submit();
return false;
}

function js_check(x){
if (x.checked==true) document.form1.ok.disabled=false;
return true;
}

function controlla_radio() {
var q=document.queryform.query.value.substring(0,6).to UpperCase();
if (q=='SELECT') {
document.queryform.costrutto[1].checked=false;
document.queryform.costrutto[0].checked=true;
}
}
function js_sql(){
if (document.queryform.costrutto[0].checked==true) {
var q=document.queryform.query.value.substring(0,6).to UpperCase();
if (q=='SELECT') {
document.queryform.action="select.php";
document.queryform.submit();
return;
}
else {
alert("La query di interrogazione deve iniziare con la clausola SELECT");
return;
}
}
else {
var input=prompt("Inserire password del DBA per l'aggiornamento del
database","");
if(input!="submit") alert("Operazione annullata");
else document.queryform.submit();
}
}
function js_cancella(){
if (confirm("I Dati cancellati non saranno pił ripristinabili - Procedere
con la cancellazione?")==true) document.form1.submit();
else {
alert("Cancellazione annullata");
history.back();
return false;
}
return false;
}
function js_modifica(){
document.form1.submit();
return false;
}

function js_home(){
if (document.formaccesso)
document.formaccesso.submit();
else location.href="welcome.php";
}

function js_valore(nomecampo){
var campo='document.form1.'+nomecampo+'.value';
alert(campo);
return campo;
}

function select_all(n){
for (i=1;i<=n;i++)
eval("document.form1.cassa"+i+".checked=true");
document.form1.ok.disabled=false;
}

function deselect_all(n){
for (i=1;i<=n;i++)
eval("document.form1.cassa"+i+".checked=false");
document.form1.ok.disabled=true;
}

function js_reparti(){
var vera='update reparti ';
var sel='select * from reparti ';
var q="set Descrizione=\'";
q=q+document.reparti.descr.value+'\' ';
q=q+' where ID_Reparto='+document.reparti.rep.value;
sel=sel+' where ID_Reparto='+document.reparti.rep.value;
vera=vera+q;
alert(vera+'\n'+sel);
document.reparti.updatequery.value=vera;
document.reparti.selectquery.value=sel;
document.reparti.submit();
}

function js_config(){
document.form1.action="sqlcommand.php";
var vera="update azienda set ";
vera=vera+"Ragione_Sociale=\'"+document.form1.rags oc.value+"\' , ";
vera=vera+"Indirizzo=\'"+document.form1.indirizzo. value+"\' , ";
vera=vera+"Cap=\'"+document.form1.cap.value+"\' , ";
vera=vera+"Citta=\'"+document.form1.citta.value+"\ ' , ";
vera=vera+"Provincia=\'"+document.form1.prov.value +"\' , ";
vera=vera+"CF=\'"+document.form1.cf.value+"\' , ";
vera=vera+"PIVA=\'"+document.form1.piva.value+"\' , ";
vera=vera+"Tel=\'"+document.form1.tel.value+"\' , ";
vera=vera+"Fax=\'"+document.form1.fax.value+"\' , ";
vera=vera+"Anno=\'"+document.form1.anno.value+"\' ";
vera=vera+"where ID_Azienda= '1'";
alert(vera);
document.form1.query.value=vera;
document.form1.tabella.value="Configurazione";
document.form1.submit();
}

function aggiorna_prezzo(){
var prezzoal=document.getElementById("prezzoal");
var contenuto=document.form1.misura.value;
vecchio=prezzoal.firstChild;
vecchio.data='Prezzo al '+contenuto+' : ';
}

function creaquery2(){
var q='update articoli set giacenza=';
q=q+js_valore('quantita');
q=q+', prezzo=';
q=q+js_valore('prezzo');
q=q+' where indice=';
q=q+js_valore('articolo');
document.form1.updatequery.value=q;
document.write(""+document.form1.updatequery.value );
}

"Brett Foster" <fo****************@ioctl.ca> ha scritto nel messaggio
news:33*************@individual.net...
Pasquale wrote:
i show here the translation of my problem from italian to english made by
google language tool ( i hope it will be not so bad).then there are the
files : accesso.php is a simple example of the strange behaviour and
articoli is something more complex (it has 2 external files)


Can't see the files. My news provider doesn't support files. Post as text
inside the message and try to make sure it's as simple an example as
possible.

the project one that I am developing has many functions JS that I have
put
in external files. until a month ago they worked well... i stopped
developing for a month for personal reasons and now that I have resumed
my
project I have noticed one matter... all the scripts come load evil
from
the browsers i use (NN and MSIE), in the sense that, as the NN
Javascript
console tells me, the files js with the functions come loaded
incomplete,
that is do not from the beginning but from a particular point
approximately
to the half of the file. that cause the loss of functions and obviously
syntax errors...


It's not a great translation, but I get the jist.

in the past month i installed some windows updates,
i use apache 2,0,52 on win xp sp2

help me... is my thesis of bachelor! thaks a lot

"Pasquale" <we*******@retailcenter.it> ha scritto nel messaggio
news:LE**********************@news4.tin.it...
hello wverybody...
i've got a terrible matter with JS

my browsers (either IE and NN) load the external scripts
uncorrectly...they load the files from the half part of them and not from
the beginning, so my scripts don't work giving syntax errors.

can you give me a solution?



Jul 23 '05 #6

P: n/a
i see the attached files are not accessible...so if you cant' access them, i
can send them to everyone wants to help me via e-mail.

thanks a lot

"Pasquale" <we*******@retailcenter.it> ha scritto nel messaggio
news:7%**********************@news4.tin.it...
i show here the translation of my problem from italian to english made by
google language tool ( i hope it will be not so bad).then there are the
files : accesso.php is a simple example of the strange behaviour and
articoli is something more complex (it has 2 external files)

the project one that I am developing has many functions JS that I have put
in external files. until a month ago they worked well... i stopped
developing for a month for personal reasons and now that I have resumed my
project I have noticed one matter... all the scripts come load evil
from
the browsers i use (NN and MSIE), in the sense that, as the NN Javascript
console tells me, the files js with the functions come loaded incomplete,
that is do not from the beginning but from a particular point
approximately
to the half of the file. that cause the loss of functions and obviously
syntax errors...

in the past month i installed some windows updates,
i use apache 2,0,52 on win xp sp2

help me... is my thesis of bachelor! thaks a lot

"Pasquale" <we*******@retailcenter.it> ha scritto nel messaggio
news:LE**********************@news4.tin.it...
hello wverybody...
i've got a terrible matter with JS

my browsers (either IE and NN) load the external scripts
uncorrectly...they load the files from the half part of them and not from
the beginning, so my scripts don't work giving syntax errors.

can you give me a solution?


Jul 23 '05 #7

P: n/a
Pasquale wrote:
<snip>

I'd move the function call into the .js file and call it from
window.onload. It may be that the browser is trying to call the function
before the .js file has fully loaded. The window.onload is not executed
until after the browser has completely loaded the page.

window.onload=js_home';

"The load event is fired at the end of the document loading process."

http://www.mozilla.org/docs/dom/domr...dow_ref63.html

Mike
Jul 23 '05 #8

P: n/a
mscir wrote:

Sorry, that should be:

window.onload=js_home;

Mike
Jul 23 '05 #9

P: n/a
yes i saw your solution but i can't do it for every page-script couple in my
project...there are some scripts not activated after page loading...

but listen this...
i discovered something new...

if i access the site via lan from my home pc (the project is on the laptop)
it doesn't do any problems...

i think this is a matter with my NN and MSIE both...it's incredible...
oh gosh...i call this a big bad luck!
Jul 23 '05 #10

P: n/a
Pasquale wrote:
yes i saw your solution but i can't do it for every page-script couple in my
project...there are some scripts not activated after page loading...

but listen this...
i discovered something new...

if i access the site via lan from my home pc (the project is on the laptop)
it doesn't do any problems...

i think this is a matter with my NN and MSIE both...it's incredible...
oh gosh...i call this a big bad luck!


- Did moving the function call into window.onload in the .js file (on
the single page you did post code for) fix that particular problem in
all browsers?

- Only use this approach where you call a function directly from a page.
I don't understand your concern about 'some scripts not activated after
page loading'. If a function is called from a button click of course you
wouldn't want it called from window.onload, maybe I'm not following you.
It would be clearer if you would post specific problems and include more
details.

Mike
Jul 23 '05 #11

This discussion thread is closed

Replies have been disabled for this discussion.