Results 1 to 8 of 8

Thread: convert an href to a js function

  1. #1
    Join Date
    Jul 2005
    Location
    Canada
    Posts
    13
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default convert an href to a js function

    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.

  2. #2
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    <a onClick="exec('sol.vbs'); return false;" href="java script:void(0)">Launch Solitare</a>
    is invalid, there is no:
    Code:
    java script:
    it is:
    Code:
    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:
    Code:
    <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?
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  3. #3
    Join Date
    Jul 2005
    Location
    Canada
    Posts
    13
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default this site only runs on home pc

    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.


    Quote Originally Posted by jscheuer1
    is invalid, there is no:
    Code:
    java script:
    it is:
    Code:
    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:
    Code:
    <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?

  4. #4
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    I don't think we need your code, and if I understand correctly, try this in your menu, where you could use:
    Code:
    javascript:alert('hello')
    You should be able to use:
    Code:
    javascript:exec('sol.vbs')
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  5. #5
    Join Date
    Jul 2005
    Location
    Canada
    Posts
    13
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    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.
    Last edited by TinmanIII; 07-09-2005 at 08:57 PM.

  6. #6
    Join Date
    Jul 2005
    Location
    Canada
    Posts
    13
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default narrowed things down a bit

    Quote Originally Posted by jscheuer1
    I don't think we need your code, and if I understand correctly, try this in your menu, where you could use:
    Code:
    javascript:alert('hello')
    You should be able to use:
    Code:
    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?

  7. #7
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    Quote Originally Posted by TinmanIII
    Code:
    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:
    Code:
    href="abcd efgh:ijkl(m)"
    Still - Whatever Works!
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  8. #8
    Join Date
    Jul 2005
    Location
    Canada
    Posts
    13
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    That has been corrected from the beginning, I just copied an pasted that from my notes.

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •