...

View Full Version : How to pass value to object data



zhixuen
06-14-2010, 06:35 AM
I want to pass the value to my object id = "Parameters"
How can I do that?
I had tried the code as posted below but it couldn't work.
I'm using document.all.Parameters.data = tempParams[0]; to pass in the data to
<OBJECT id="Parameters" style="Z-INDEX: 200; LEFT: 0px; TOP: 0px; POSITION: ABSOLUTE;" type=application/pdf height=800
width=1060 VIEWASTEXT scroll=yes></OBJECT>
I also have tried document.getElementById("Parameters").data = tempParams[0]; but still doesn't work.

The code attached as below.


<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">



<html>
<head>
<title>Management System Manual</title>



<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">

<script language="JavaScript" type="text/JavaScript">
<!--
function MM_reloadPage(init) { //reloads the window if Nav4 resized
if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}
MM_reloadPage(true);

function right(e) {
if (navigator.appName == 'Netscape' &&
(e.which == 3 || e.which == 2))
return false;
else if (navigator.appName == 'Microsoft Internet Explorer' &&
(event.button == 2 || event.button == 3)) {
alert("Sorry, you do not have permission to right click.");
return false;
}
return true;
}

document.onmousedown=right;
document.onmouseup=right;
if (document.layers) window.captureEvents(Event.MOUSEDOWN);
if (document.layers) window.captureEvents(Event.MOUSEUP);
window.onmousedown=right;
window.onmouseup=right;
// End -->
</script>

<script type="text/javascript" language="JavaScript1.2">
<!-- // Begin
//Disable right click script
//no alert

var message="";
///////////////////////////////////

function onKeyDown() {
if ( (event.altKey) || ((event.keyCode == 8) &&
(event.srcElement.type != "text" &&
event.srcElement.type != "textarea" &&
event.srcElement.type != "password")) ||
((event.ctrlKey) && ((event.keyCode == 82)) ) ||
(event.keyCode == 68) ||
(event.keyCode == 80) ||
(event.keyCode == 78) ||
(event.keyCode == 66) ||
(event.keyCode == 72) ||
(event.keyCode == 73) ||
(event.keyCode == 74) ||
(event.keyCode == 70) ||
(event.keyCode == 122)
) {
event.keyCode = 0;
event.returnValue = false;
}
}

function clickIE() {if (document.all) {(message);return false;}}
function clickNS(e) {if
(document.layers||(document.getElementById&&!document.all)) {
if (e.which==2||e.which==3) {(message);return false;}}}
if (document.layers)
{document.captureEvents(Event.MOUSEDOWN);document.onmousedown=clickNS;}
else{document.onmouseup=clickNS;document.oncontextmenu=clickIE;}

document.oncontextmenu=new Function("return false")




// End -->
</script>
<script type="text/javascript" language="JavaScript1.2">


function getParams() {
var idx = document.URL.indexOf('?');
var idx1 = document.URL.indexOf('#');
var tempParams = new Object();

if (idx != -1) {
var pairs = document.URL.substring(idx+1, idx1).split('?');

//pairs = 1;
for (var i=0; i<pairs.length; i++) {
nameVal = pairs[i].split('=');

tempParams[0] = nameVal[1];
}
}

//document.getElementById("Parameters").data = tempParams[0];
//document.all.Parameters.data = tempParams[0];

document.all.Parameters.data = tempParams[0];
//alert (window.document.parameters.data);

return false;
}


</script >

</head>

<style media="print">
body
{
display : none;
}
</style>

</HEAD>

</head>

<!-- <body ondragstart="return false" onselectstart="return false" onkeydown=onKeyDown() onload=setInterval("window.clipboardData.clearData();getParams();",2) oncontextmenu="return false" scroll=yes > -->
<body ondragstart="return false" onselectstart="return false" onkeydown=onKeyDown() onload=getParams() oncontextmenu="return false" scroll=yes >

<!--<input id="abc" type="text"/>-->
<form id="frmRestricted" method="post">

<div id="Layer2" style="position:absolute; left:0px; top:-35px; width:1060; height:800; z-index:201">
<OBJECT id="Parameters" style="Z-INDEX: 200; LEFT: 0px; TOP: 0px; POSITION: ABSOLUTE;" type=application/pdf height=800
width=1060 VIEWASTEXT scroll=yes></OBJECT>
</div>
</form>
</body>
</html>

Thank you very much

Kor
06-14-2010, 10:05 AM
First at all, bring your code up-to-date. References like document.all (old IE) and document.layers (Netscape) are medieval. In modern javascript, references are to be done upon id - document.getElementById(); in some cases by name - document.getElementsByName(); by their tag name - document.getElementsByTagName(); or by their position in DOM tree - as childNodes or sibling position.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum