link help

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • timothy ma and constance lee

    #1

    link help

    sir

    I have html page a that have a link to page b.

    Page b are very similar to page c and d,except some fields so I would like
    to combine them as Page common.html.

    Can I pass the parameter from page a.html so that the parameters can
    determine which fields to be displayed in common.html?


  • Robert

    #2
    Re: link help

    In article <K9bMd.253012$8 l.44142@pd7tw1n o>,
    "timothy ma and constance lee" <timcons1@shaw. ca> wrote:
    [color=blue]
    > sir
    >
    > I have html page a that have a link to page b.
    >
    > Page b are very similar to page c and d,except some fields so I would like
    > to combine them as Page common.html.
    >
    > Can I pass the parameter from page a.html so that the parameters can
    > determine which fields to be displayed in common.html?[/color]
    The first file includes a little other stuff, but it does show you how
    to pass a parameter. robert

    How to pass a parameter:

    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
    <HTML>
    <HEAD>
    <TITLE>Read variables</TITLE>

    <SCRIPT type="text/javascript">

    function foo()
    {
    var theData, newWindow, URLstring;
    //You can pass around 2k of data.
    theData = "?data=" + escape("boldpar agraph");
    URLstring = "readVars.h tml" + theData;

    newWindow = window.open(URL string,"Printab le",
    "statusbar,menu bar,resizable,t oolbar,height=6 00,width=800");
    newWindow.focus ();
    }


    // ------------------------------------------

    // This function takes a Node n, replaces
    // it in the tree with an Element node
    // that represents an HTML <b> tag, and
    // then makes the original node the
    // child of the new <b> element.

    // From: Javascript: The Definitive Guide by David Flanagan

    function embolden(node)
    {
    var bold = document.create Element("b");
    var parent = node.parentNode ;

    parent.replaceC hild(bold,node) ;
    bold.appendChil d(node);
    }


    </script>

    </HEAD>

    <BODY onload='
    alert("bold text next");
    embolden(docume nt.getElementBy Id("inlineparag raph"));
    alert("Try to open a new window next.");
    foo();
    //alert("Tried to open the window.");'>

    <p><br>Lets open a window and pass data to the window.</p>
    <p id="inlineparag raph">A Javascript function in this file
    will bold <i>this</i> paragraph.</p>
    <p id="boldparagra ph">A Javascript function in the call html file
    will bold this paragraph <i>is</i> paragragh.</p>

    </BODY>

    </HTML>



    How to read the parameter:

    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
    <HTML>
    <HEAD>
    <TITLE>Read passed data</TITLE>

    <SCRIPT type="text/javascript">
    var theData;

    function foo2()
    {

    var begin;

    begin = location.search .indexOf("data= ");

    if (begin >0 )
    {

    theData = location.search .substring(begi n+5,location.se arch.length);
    theData = unescape(theDat a);
    document.write( "<p>Here is the passed data:</p>");
    document.write( theData + "<\/p>");
    }
    else
    {
    document.write( "Could not find passed"
    + " variable \"data=\" with escaped data.")
    }
    }
    </script>

    </HEAD>
    <BODY onload='
    alert("bold text in opener document");
    opener.embolden (opener.documen t.getElementByI d(theData));'[color=blue]
    >[/color]

    <p>What is the deal?</p>
    <SCRIPT type="text/javascript">
    document.write( "<p>");
    foo2()
    document.write( "<\/p>");
    </script>
    </BODY>

    </HTML>


    Robert

    Comment

    Working...