Log in

View Full Version : convert an href to a js function



TinmanIII
07-09-2005, 02:40 AM
I have learned how to do that but now i have run into something new.
This href includes vb.

can someone convert this line into a javascript function for me?

<a onClick="exec('sol.vbs'); return false;" href="java script:void(0)">Launch Solitare</a>

I'm almost at my goal and this line has confused me.
Thank you.

jscheuer1
07-09-2005, 05:39 AM
<a onClick="exec('sol.vbs'); return false;" href="java script:void(0)">Launch Solitare</a>is invalid, there is no:

java script:it is:

javascript:Now, aside from being a little poorly written, the line would at least be valid and, already contains elements of javascript. I'd write it like this:

<a href="nojavascript.htm" onClick="exec('sol.vbs'); return false;" >Launch Solitaire</a>Where nojavascript.htm is a page explaining that the user needs javascript enabled to play the game.
What exactly did you have in mind?

TinmanIII
07-09-2005, 06:22 AM
I would not need a separate page to qualify whether a person was using JS or not.
Since I had much larger problems to tackle with my site, I decided to use a wysiwyg menu program (Xara).
I have invested so much time trying to save myself time by using this program, that it seems it is my only stumbling block.
It will accept JS as:
javascript:fullwin('Pictures.htm')
where fullwin is defined as a function.
javascript:alert('hello')
is another example,
I just don't know how to give the Xara program, the right syntax for this function.

<a onClick="exec('sol.vbs'); return false;" href="java script:void(0)">Launch Solitare</a>

I have a vb script and a js script that apply to this line.
I didn't anticipate that they would be needed to answer this Q of mine, but I'd be happy to post them.

Thanks again.



is invalid, there is no:

java script:it is:

javascript:Now, aside from being a little poorly written, the line would at least be valid and, already contains elements of javascript. I'd write it like this:

<a href="nojavascript.htm" onClick="exec('sol.vbs'); return false;" >Launch Solitaire</a>Where nojavascript.htm is a page explaining that the user needs javascript enabled to play the game.
What exactly did you have in mind?

jscheuer1
07-09-2005, 12:46 PM
I don't think we need your code, and if I understand correctly, try this in your menu, where you could use:

javascript:alert('hello')
You should be able to use:

javascript:exec('sol.vbs')

TinmanIII
07-09-2005, 08:41 PM
Thanks Jscheuer1
That works, I never tried just dumping the rest of the line, but it seems to work.
Thanks again.
after checking it seems I will somehow need the rest of the line
a onClick="exec('sol.vbs'); return false;" href="java script:void(0)">Launch Solitare
that line works well with all users embedded in the html,

but javascript:exec('sol.vbs') inserted into the menu program only works for the admin user, not any of the other users when they view the page.
thanks again, i'll keep trying.

TinmanIII
07-10-2005, 01:14 AM
I don't think we need your code, and if I understand correctly, try this in your menu, where you could use:

javascript:alert('hello')
You should be able to use:

javascript:exec('sol.vbs')

Ok this is what I have figured out:

javascript:exec('switchuser.vbs') added into my navbar program

<a onClick="exec('switchuser.vbs'); return false;" href="javascript:void(0)">Switch User</a><p align="center">
added into my html

both lines work in all users

BUT
the javascript line will not work with MS "active desktop" in any of the user accounts.

I receive an "error" window:
a runtime error has occurred
line 0
error:object expected

I also get another browser window popping up with javascript:exec('switchuser.vbs')
in the address bar.


if I open up my browser (IE6 SP2) with my "home page" set as c:\mywebsite\index.htm
both lines ( the JS and the href ) will work fine for any user account.

so I am not really sure where my problem lies here.
I would expect that it's "active desktop" issue but am not sure why I am getting a runtime error.

Any thoughts?

jscheuer1
07-10-2005, 01:16 AM
a onClick="exec('sol.vbs'); return false;" href="java script:void(0)">There you go again with that 'java script'. That should be meaningless. It could be a proprietary thing for that specific menu but, in general, it is equivalent to:

href="abcd efgh:ijkl(m)"Still - Whatever Works!

TinmanIII
07-10-2005, 01:37 AM
That has been corrected from the beginning, I just copied an pasted that from my notes.