Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

how to convert name of variable to URL opened within object tag? 1

Status
Not open for further replies.

conrai

Programmer
Nov 21, 2004
10
FI
Hello! I have the following problem.

I have the HTML page "reports.html". It contains a number of hrefs for displaying different reports (in HTML format). All those links refer to the same page "reportsDisplayer.html" but i pass different reportnames to reportsDisplayer by adding them with a question mark to the end of the URL.

e.g. in reports.html:
<a href="reportDisplayer.html?REPORT=xyz.html">xyz</a>

In reportDisplayer.html I save the name of the passed REPORT into the variable reportName by calling the appropriate javascript function.

So far everything is fine. In variable "reportName" i have now for example saved the value "xyz.html".

AND NOW: i would like to use this reportName variable for opening the xyz.html as an object within the reportDisplayer.html site.

If I indicate the report-url (data) statically it works, e.g.:
<object width="100%" height="100%" type="text/html" data="xyz.html" border="0" style="overflow: auto"></object>

But how can I achieve, that the opened object depends on the value saved in the reportName variable? How can I transform it to an URL and integrate it to the <object> tag?

like
<object width="100%" height="100%" type="text/html" data=reportName border="0" style="overflow: auto"></object>

Hope there is at all a solution for this problem without using JSP/PHP..

Thanks already now for your help!

br,
Konrad
 
I would normally do this with an iFrame but try this...

<object id="myObject" width="100%" height="100%" type="text/html" data=reportName border="0" style="overflow: auto"></object>


<body onLoad="document.getElementById('myObject').data='xyz.html'">

You might need to get the attributes associated with the object to see if ".data" is correct.

Programming today is a race between software engineers striving to build better and bigger idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning. - Rick Cook (No, I'm not Rick)

zen.gif
 
Thank you mwolf00,

but then it's still the same problem, when I write

<body onLoad="document.getElementById('myObject').data='xyz.html'">
then i want to replace "xyz.html" with the javascript variable specifying the url

Let's say I use an IFrame:
<iframe src="xyz.html" width="90%" height="90%">
</iframe>

I would like to replace the src then with the content of my Javascript variable (e.g. a String converted to URL) whichs value depends on from where the page was called...

Unfortunately I'm quite unexperienced with JavaScript :-|

br
 
How about
Code:
document.getElementById('myObject').setAttribute('data','xyz.html');

--Chessbot

"Violence is the last refuge of the incompetent." -- Asimov, Foundation
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top