| re: link help
In article <K9bMd.253012$8l.44142@pd7tw1no>,
"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("boldparagraph");
URLstring = "readVars.html" + theData;
newWindow = window.open(URLstring,"Printable",
"statusbar,menubar,resizable,toolbar,height=600,wi dth=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.createElement("b");
var parent = node.parentNode;
parent.replaceChild(bold,node);
bold.appendChild(node);
}
</script>
</HEAD>
<BODY onload='
alert("bold text next");
embolden(document.getElementById("inlineparagraph" ));
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="inlineparagraph">A Javascript function in this file
will bold <i>this</i> paragraph.</p>
<p id="boldparagraph">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(begin+5,location.search. length);
theData = unescape(theData);
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.document.getElementById(the Data));'[color=blue]
>[/color]
<p>What is the deal?</p>
<SCRIPT type="text/javascript">
document.write("<p>");
foo2()
document.write("<\/p>");
</script>
</BODY>
</HTML>
Robert |