Function that returns to original frame

Discussion in 'JavaScript' started by sooline, Dec 14, 2005.

  1. #1
    I have an XML documented which was converted to HTML. When a user
    clicks on an animation or jpeg link, the single frame view is split into two frames: Text on the left frame and the animation or figure displayed in the right frame. I think need to include a variation of the script:

    onClick="MM_goToURL('parent','frameset.htm');return document.MM_returnValue"

    The right frame should probably have a close script like:

    <FORM>
    <INPUT TYPE="BUTTON" VALUE="Go Back"
    ONCLICK="history.go(-1)">
    </form>

    Unfortunately, I have close to 60 steps, which all require a split display and the functionality to return to the main frame. Rather than create 60 frame.htm files, I need help tweaking the script to reuse the same right frame every time I open an animation. Below is the On_Double_Click script that I have now to hyperlink to the figures and animation.

    function onDoubleClick() {

    var rng = ActiveDocument.Range;
    var currentNode = rng.ContainerNode;

    // check if
    if (!currentNode)
    return;

    rng.SelectNodeContents(currentNode);

    if (currentNode.nodeName == "ulink")
    onDoubleClickULink(rng);

    }

    // Launch default application depending on filename specified
    function onDoubleClickULink(select)
    {

    // local vars
    var sFilename = "";
    WSHShell = new ActiveXObject("WScript.Shell");

    // make sure there is a URL attribute and read its value
    if (select.ContainerNode.hasAttribute("URL"))
    sFilename = select.ContainerAttribute("URL");
    else
    {
    // Do we want to tell the user it doesnt have a URL attribute
    // or do we simply want to return ? For now we'll just return
    // Application.Alert("No URL attribute specified on current ULink element.");
    return;
    }

    // Verify if the document exists or not
    oFSO = new ActiveXObject("Scripting.FileSystemObject")
    if (!oFSO.FileExists(sFilename))
    {
    // Do we want to tell the user that the file doesnt exists or
    // do we just return ? For now we'll tell the user AND return
    Application.Alert("The file path is invalid.");
    return;
    }

    // Run command to open URL...
    WSHShell.Run("rundll32 url.dll,FileProtocolHandler " + sFilename, 1, false);

    // Cleanup...
    WSHShell = null;

    }

    onDoubleClick()

    I apologize for posting two requests in one thread, but they are related. I would appreciate any help or direction on resolving one or both functions. Thanks - sooline
     
    sooline, Dec 14, 2005 IP