469,917 Members | 1,489 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,917 developers. It's quick & easy.

Error with Mozilla with automatic launch.....

Hi all,

I'm currently developping a web app, and this one must be compatible
with IE and Mozilla Firefox. In this webapp, I would like to launch
automatically a anchor link (href) with a javascript script.

My Javascript script works fine with IE but not with Mozilla Firefox.

Here is my script :
<script language="Javascript">
strAppFound = new String("True")
if(strAppFound.toLowerCase()=="true"){
window.lnkApp.click();
}
The error returned by Mozilla Firefox Console Javascript is :
Erreur : window.lnkApp has no properties
Fichier Source : http://localhost/test.aspx
Ligne : 806

The HTML code (href link) is the following, that should be launch
automatically is :

<a class="appLinks"
href="launch.ica?NFuse_Application=Citrix.MPS.App. f10_col.myApplication&NFuse_AppFriendlyNameURLENco ded=myApplication"
target="hiddenwindow" onClick="resetSessionTimeout(); " id="lnkApp"
name="lnkApp">

<img src="icons.aspx?id=EIBHKDOECEIJBMKHEDKFFICKKPGHHAF K"
border="0"
alt="myApplication"
title="myApplication"
align=bottom hspace=3 width="32" height="32"><br>
myApplication<br>
</a>

Everything works fine with IE browser...
Any one have an idea to solve this trouble ?

Thanks

Sep 22 '05 #1
4 2181
au*******@yahoo.fr wrote:
Hi all,

I'm currently developping a web app, and this one must be compatible
with IE and Mozilla Firefox. In this webapp, I would like to launch
automatically a anchor link (href) with a javascript script.

My Javascript script works fine with IE but not with Mozilla Firefox.

Here is my script :
<script language="Javascript">
The language attribute is depreciated, type is required.

<script type="text/javascript">

strAppFound = new String("True")
I'll guess that the point of initialising a string object to some value,
then immediately testing it to see what the value is that this is just a
test harness...

There is no need for string object, you don't seem to need it, a boolean
will do the job:

strAppFound = true;

if(strAppFound.toLowerCase()=="true"){
Having made strAppFound a boolean, you can no do:

if ( strAppFound ) {

window.lnkApp.click();
Here you are using the id of an element as a global variable. That is
an IE-ism and should not be expected to work elsewhere. If you are
writing only for modern browsers (anything after IE 5 or Netscape 4) use:

document.getElementById('lnkApp').click()

It is easy to add support for older IE and Nescape if you want to
support them too (do a search in the newsgroup for document.all and
document.getElementById or poke around the FAQ).

The next issue you have is how widely the click method is supported in
various browsers for the element you have selected. As far as I know,
it's not well supported at all. Firefox will tell you that:

document.getElementById('lnkApp').click() is not a function

Since you know it's a link, get its href attribute and use it to change
the window.location. Replace the above with:

window.location = document.getElementById('lnkApp').href;

}
The error returned by Mozilla Firefox Console Javascript is :
Erreur : window.lnkApp has no properties
Fichier Source : http://localhost/test.aspx
Ligne : 806

The HTML code (href link) is the following, that should be launch
automatically is :

[...]
--
Rob
Sep 22 '05 #2
au*******@yahoo.fr wrote:
Hi all,

I'm currently developping a web app, and this one must be compatible
with IE and Mozilla Firefox. In this webapp, I would like to launch
automatically a anchor link (href) with a javascript script.

My Javascript script works fine with IE but not with Mozilla Firefox.

Here is my script :
<script language="Javascript">
strAppFound = new String("True")
if(strAppFound.toLowerCase()=="true"){
window.lnkApp.click();
}
The error returned by Mozilla Firefox Console Javascript is :
Erreur : window.lnkApp has no properties
Fichier Source : http://localhost/test.aspx
Ligne : 806

The HTML code (href link) is the following, that should be launch
automatically is :

<a class="appLinks"
href="launch.ica?NFuse_Application=Citrix.MPS.App. f10_col.myApplication&NFuse_AppFriendlyNameURLENco ded=myApplication"
target="hiddenwindow" onClick="resetSessionTimeout(); " id="lnkApp"
name="lnkApp">

<img src="icons.aspx?id=EIBHKDOECEIJBMKHEDKFFICKKPGHHAF K"
border="0"
alt="myApplication"
title="myApplication"
align=bottom hspace=3 width="32" height="32"><br>
myApplication<br>
</a>

Everything works fine with IE browser...
Any one have an idea to solve this trouble ?

Thanks


You are counting on the browser creating javascript objects that
reference the elements on the page. IE will create an opbject called
"foo" if there's an element on the page with an ID of "foo". Firefox /
Mozilla will do this too, but only under certain conditions (I don't
know what they are, I think it's only form elements in a form - but
don't quote me on that!).

It's best to assume that those references don't exist and you should
Define and Assign them for any element that you wish to refference.

like this :

Add : var lnkApp = document.getElementById("lnkApp");
and remove the "window." before the call to lnkApp.click();

Hope that helps

Andy

----------------------------------
my javascript notepad
----------------------------------
- http://km0ti0n.blunted.co.uk -
----------------------------------
Sep 22 '05 #3
Hi,

au*******@yahoo.fr wrote:
Hi all,

I'm currently developping a web app, and this one must be compatible
with IE and Mozilla Firefox. In this webapp, I would like to launch
automatically a anchor link (href) with a javascript script.

My Javascript script works fine with IE but not with Mozilla Firefox.

Here is my script :
<script language="Javascript">
strAppFound = new String("True")
if(strAppFound.toLowerCase()=="true"){
window.lnkApp.click();
}


Don't do it this way. Instead,
1.Create a function to open the link in a new window.
2.Then call that function in body "onload".

That way it will work in all browsers i feel.

for mozilla, firefox or IE, try
document.getElementById('lnkApp').click(). Hope it works.

-- Peroli Sivaprakasam

Sep 22 '05 #4
Thank you very much to all of you
window.location = document.getElementById('lnkApp').href; WORKS ! ;)

Sep 22 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

4 posts views Thread by Jay Davis | last post: by
2 posts views Thread by Peter | last post: by
67 posts views Thread by Steven T. Hatton | last post: by
6 posts views Thread by Peter Frost | last post: by
4 posts views Thread by Maileen | last post: by
6 posts views Thread by p175 | last post: by
reply views Thread by Salome Sato | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.