Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

getting information (xml attribute) in frame with HTML code from other frame

 
Tom Brown
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hey there
i want to get information (xml attribute: @ID) in a frame with HTML code from other frame (xml and xsl) when i click the button in the htmlframe to switch the language. so i can have the same href in my frameset with an other language attribute.
When i push the button in the html page it refers to an frameset where i need the same link as in the mainframe but in an other language. so i can switch language and stay on the same page an not at the startpage.
Is it possible to get information from an other frame with an onclick-action or something else?
Can somebody help me please?
thanks a lot.
Tom
[ October 29, 2003: Message edited by: Tom Brown ]
 
Eric Pascarello
author
Rancher
Posts: 15385
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Okay,
Yes you can get infomation from another frame
this line will change the page location of a frame:
parent.FRAMENAME.document.location.href = BLAH
you can pass it with onclick...
Do you need help reading the xml with JavaScript....I have done it once before and I might be bale to figure out how to read it again.
Eric
 
Tom Brown
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thanks eric for the reply,
i'll give some more information. maybe that helps.
I hope that i can explain my problem.


* I work with 2 index pages. index_nl and index_fr
* navframe with xml/xsl stylesheet.
* mainframe with xml/xsl stylesheet. in every xml file there is a <LANG>NL</LANG> or <LANG>FR</LANG>.
* I show 2 different xml-files in the mainframe. One page with toc of products and when you pick one product you go to the product in the same frame. In that xml-file there is a reference to the productnumber.
* when i am in the NL-language and push the FR-language button to go to the other language i want to give the same pages, but in the other language.

what can i do? when i push the button i have to trace which xml file is loaded in the mainframe. then i have to send it to the other indexpage to show the right page in the mainframe but in the other language. I have 2 sort of files to show in the mainframe. One toc-file wich is made by starting the page.. so thats an easy url-link. And in the other case i have to give a command to import the right xml product file.

is there an other solution? maybe an refresh button and a tool or something to catch some data from the mainframe?

i hope you can help

-------------
index_nl.htm
-------------
<frameset rows="100,375" frameborder="NO" border="0" framespacing="0">
<frame name="topframe" src="html/top_testfrans.htm" marginwidth="0" marginheight="0" scrolling="no" frameborder="0" noresize>
<frameset cols="325,455">
<frameset rows="120,255">
<frameset cols="160,165">
<frame name="zoekframe" src="html/form_tech.htm" marginwidth="0" marginheight="0" scrolling="no" frameborder="0" noresize>
<frame name="fotoframe" src="html/empty_foto.htm" marginwidth="0" marginheight="0" scrolling="no" frameborder="0" noresize>
</frameset>
<frame name="navframe" src="http://.....toc=MAIN_NL" marginwidth="0" marginheight="0" scrolling="no" frameborder="0" noresize>
</frameset>
<frame name="mainframe" src="html/empty.htm" marginwidth="0" marginheight="0" scrolling="yes" frameborder="0">
</frameset>
</frameset>
-----------------

-----------------
index_fr.htm
-----------------
<frameset rows="100,375" frameborder="NO" border="0" framespacing="0">
<frame name="topframe" src="html/top_fr.htm" marginwidth="0" marginheight="0" scrolling="no" frameborder="0" noresize>
<frameset cols="325,455">
<frameset rows="120,255">
<frameset cols="160,165">
<frame name="zoekframe" src="html/form_tech_fr.htm" marginwidth="0" marginheight="0" scrolling="no" frameborder="0" noresize>
<frame name="fotoframe" src="html/empty_foto.htm" marginwidth="0" marginheight="0" scrolling="no" frameborder="0" noresize>
</frameset>
<frame name="navframe" src="...?table=PUBLI&toc=TOC_NL" marginwidth="0" marginheight="0" scrolling="no" frameborder="0" noresize>
</frameset>
<frame name="mainframe" src="html/empty.htm" marginwidth="0" marginheight="0" scrolling="yes" frameborder="0">
</frameset>
</frameset>
-------------------


this is my top file in html. there are 3 layers for navigate. one button to switch the language. i have reduced the code. normally its code with onmouseover and stuff...
--------------------
top_testfrans.htm
--------------------
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Untitled</title>
</head>
<body leftmargin="0" topmargin="0" rightmargin="0" bottommargin="0">
<div id="tech1" style="position:absolute; left:5; top:70; width:155px; height:30px; z-index:1; cursor:hand;"><a>lt;/a></div>
<div id="tech2" style="position:absolute; left:5; top:70; width:155px; height:30px; z-index:1; visibility: hidden;"><img src="../bot_tech_1.gif" width="155" height="30"></div>
<div id="tech3" style="position:absolute; left:5; top:70; width:155px; height:30px; z-index:1</div>
<div id="werk1" style="position:absolute; left:160; top:70; width:155px; height:30px; z-index:1; cursor:hand;"><a></a></div>
<div id="werk2" style="position:absolute; left:160; top:70; width:165px; height:30px; z-index:1; visibility: hidden;"></div>
<div id="product1" style="position:absolute; left:330; top:70; width:190px; height:30px; z-index:1; cursor:hand;"><a></a></div>
<div id="product2" style="position:absolute; left:330; top:70; width:190px; height:30px; z-index:1; visibility: hidden;"></div>
<table bgcolor="#666666" width="780" height="100" cellspacing="0" cellpadding="0" border="0">
<td height="30" width="115" bgcolor="#ffffff" nowrap><a href="../WEB/index_fr.html" target="_parent"><img src="../bot_fra_1.gif" name="frans1" width="115" height="30" border="0" id="frans1"></a></td>
<td height="30" width="5" bgcolor="#fffffff" nowrap><img src="../bot_right.gif" width="5" height="30"></td>
</tr>
</table>
</body>
</html>
--------------

---------------------------
example toc.xml products in mainframe
---------------------------
<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" href="../XSL/toc.subnav.xsl"?>
<PRODS HNAME="">
<LANG>FR</LANG>
<TITLE>Product</TITLE>
<TECHCARD ID="TS005" NAME="productname" DESCRPT="description" IMAGE="P0055.jpg" TYPE="type" STYPE="stype" />
</TECHCARDS>
-----------------------

------------
example product in mainframe with product number.
------------
<?xml version="1.0" encoding="iso-8859-1" standalone="yes"?>
<?xml-stylesheet type="text/xsl" href="../XSLT/pub.product.xsl"?>
<PRODUCT_f>
<LANG>FR</LANG>
<TYPE>type</TYPE>
<STYPE>stype</STYPE>
<TRANSPORT">
<product TYPE="1" CODE="TS005">
<PRODUCT NR="TS005">
<AL>
<PARA></PARA>
</AL>
</Product></TRANSPORT></product_f>
-----------------------------------

i hope you have enough information.

really thanks a lot !!

i hope somebody can help me.

Tom
 
Eric Pascarello
author
Rancher
Posts: 15385
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I can probably make this easier then having to hae to read the XML to figure out what is going on.
Basically if you click a link you want to change the source of two frames which will change the language?
You know what the button says to change too right?
Eric
 
Tom Brown
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hey
maybe I can solve my problem when I can get the url-adress of the mainframe when i click in the topframe on the language button.
how can i do that?
thanks
Tom
 
Eric Pascarello
author
Rancher
Posts: 15385
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
you can get the addy by using that document.location.href statement
thePage = parent.MainFrameName.location.href;
You can get the "bread crumbs" of the navigation by doing the following
theParts = thePage.split("/");
so that places each folder/directory into an array
therefor the last part of the array will contain the page of the mainframe
theActualPage = theParts[theParts.length-1];
then you need to pull off the nl or fr??
thePageParts = theActualPage.split(".");
theLanguage = thePageParts[0].slice(thePageParts[0].length-2,thePageParts[0].length);
then you would be left with the nl or fr
ugly code, could be simplified a bit, but it might help you out
Eric
 
Tom Brown
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thanks eric for the reply
i get the url adress in my top frame doing this, but i have troubles to implement the code i've received from you to split the code and give an other language (example NL to FR) to the new adress.
-------
script
-------
var othermainframeurl = parent.mainframe.location.href;
var otherzoekframeurl = parent.zoekframe.location.href;
var othernavframeurl = parent.navframe.location.href;
var otherfotoframeurl = parent.fotoframe.location.href;
alert( othermainframeurl );
alert( otherzoekframeurl );
alert( othernavframeurl );
alert( otherfotoframeurl );

function replaceframes(othernavframeurl, othermainframeurl, otherfotoframeurl, otherzoekframeurl){
parent.navframe.location.href = othernavframeurl';
parent.mainframe.location.href = othermainframeurl';
parent.fotoframe.location.href = otherfotoframeurl';
parent.zoekframe.location.href = otherzoekframeurl';
-------------------
the language button
-------------------
<a href="http://server/WEB/HTML/topfr.htm" onKKKlick="parent.navframe.location='javascript:replaceframes'; parent.mainframe.location='javascript:replaceframes'; parent.fotoframe.location='javascript:replaceframes'; parent.zoekframe.location='javascript:replaceframes'">
--------------------------
example of receiving url:
--------------------------
http://server/WEB/TOC_1_NL.xml
or maybe easyer...??
http://server/WEB/NL_TOC_1.xml
--------------------------
example of sending url back to mainframe for with other language:
--------------------------
http://server/WEB/TOC_1_FR.xml
http://server/WEB/FR_TOC_1.xml
so I just want to edit the receiving adres to cut the NL and replace by FR.
i've tried to implemend the code but it didn't work...
can you show how i can do that?
thanks Eric.
Tom
[ October 31, 2003: Message edited by: Tom Brown ]
[ October 31, 2003: Message edited by: Tom Brown ]
[ October 31, 2003: Message edited by: Tom Brown ]
 
Tom Brown
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hey
i've tried to implement the code that you wrote, but it still not work.
Can you give me an idea to do it?
----------------------------------------
example getting url:
http://server/plus/PRODUCT/WEB/TOC/TOC_NL_ZA_2_1_1_2_2_1.xml
wanting url with onKKKlick:
http://server/plus/PRODUCT/WEB/TOC/TOC_FR_ZA_2_1_1_2_2_1.xml
-----------------------------------------
var the_url1 = parent.mainframe.location.href;
var the_url2 = parent.navframe.location.href;
var the_url3 = parent.topframe.location.href;
var the_url4 = parent.fotoframe.location.href;
var the_url5 = parent.zoekframe.location.href;

var first_split1 = the_url1.split("_");
var first_split2 = the_url2.split("_");
var first_split3 = the_url3.split("_");
var first_split4 = the_url4.split("_");
var first_split5 = the_url5.split("_");

var first_part1 = first_split1[0];
var first_part2 = first_split2[0];
var first_part3 = first_split3[0];
var first_part4 = first_split4[0];
var first_part5 = first_split5[0];

var flang1 = first_split1[1];
var flang2 = first_split2[1];
var flang3 = first_split3[1];
var flang4 = first_split4[1];
var flang5 = first_split5[1];

var fcat1 = first_split1[2];
var fcat2 = first_split2[2];
var fcat3 = first_split3[2];
var fcat4 = first_split4[2];
var fcat5 = first_split5[2];

var fnuma1 = first_split1[3];
var fnuma2 = first_split2[3];
var fnuma3 = first_split3[3];
var fnuma4 = first_split4[3];
var fnuma5 = first_split5[3];

var fnumb1 = first_split1[4];
var fnumb2 = first_split2[4];
var fnumb3 = first_split3[4];
var fnumb4 = first_split4[4];
var fnumb5 = first_split5[4];

var fnumc1 = first_split1[5];
var fnumc2 = first_split2[5];
var fnumc3 = first_split3[5];
var fnumc4 = first_split4[5];
var fnumc5 = first_split5[5];

var fnumd1 = first_split1[6];
var fnumd2 = first_split2[6];
var fnumd3 = first_split3[6];
var fnumd4 = first_split4[6];
var fnumd5 = first_split5[6];

var fnume1 = first_split1[7];
var fnume2 = first_split2[7];
var fnume3 = first_split3[7];
var fnume4 = first_split4[7];
var fnume5 = first_split5[7];

var fnumf1 = first_split1[8];
var fnumf2 = first_split2[8];
var fnumf3 = first_split3[8];
var fnumf4 = first_split4[8];
var fnumf5 = first_split5[8];

var fnumg1 = first_split1[9];
var fnumg2 = first_split2[9];
var fnumg3 = first_split3[9];
var fnumg4 = first_split4[9];
var fnumg5 = first_split5[9];

var fnumh1 = first_split1[10];
var fnumh2 = first_split2[10];
var fnumh3 = first_split3[10];
var fnumh4 = first_split4[10];
var fnumh5 = first_split5[10];

function newURL1(){
var newURL1 = (first_part1 + '_' + FR + '_' + fcat1 + '_' + fnuma1 + fnumb1 + fnumc1 + fnumd1 + fnume1 + fnumf1 + fnumg1 + fnumh1);
}
function newURL2(){
var newURL2 = (first_part2 + '_' + FR + '_' + fcat2 + '_' + fnuma2 + fnumb2 + fnumc2 + fnumd2 + fnume2 + fnumf2 + fnumg2 + fnumh2);
}
function newURL3(){
var newURL3 = (first_part3 + '_' + FR + '_' + fcat3 + '_' + fnuma3 + fnumb3 + fnumc3 + fnumd3 + fnume3 + fnumf3 + fnumg3 + fnumh3);
}
function newURL4(){
var newURL4 = (first_part4 + '_' + FR + '_' + fcat4 + '_' + fnuma4 + fnumb4 + fnumc4 + fnumd4 + fnume4 + fnumf4 + fnumg4 + fnumh4);
}
function newURL5(){
var newURL5 = (first_part5 + '_' + FR + '_' + fcat5 + '_' + fnuma5 + fnumb5 + fnumc5 + fnumd5 + fnume5 + fnumf5 + fnumg5 + fnumh5);
}

function refresh_frames(newURL1, newURL2, newURL3, newURL4, newURL5) {
parent.mainframe.location.href= newURL1(first_part1 + '_' + FR + '_' + fcat1 + '_' + fnuma1 + fnumb1 + fnumc1 + fnumd1 + fnume1 + fnumf1 + fnumg1 + fnumh1);
parent.navframe.location.href= newURL2();
parent.topframe.location.href= newURL3();
parent.fotoframe.location.href= newURL4();
parent.zoekframe.location.href= newURL5();
}
function get_URL() {
parent.MainFrame.location.href = (parent.MainFrame.location.href + '&LANG=' + FR);
}
--------------------------------------
<a href="http://server/WEB/HTML/top_fr.htm" onKKKlick="parent.mainframe.location=newURL1(); parent.navframe.location=newURL2(); parent.topframe.location=newURL3(); parent.fotoframe.location=newURL4(); parent.zoekframe.location=newURL5();">
or
<a href="http://server/WEB/HTML/top_fr.htm" onKKKlick="javascript:refresh_frames;">
--------------------------------------
what do i wrong?
thanks very much.
Tom
[ November 03, 2003: Message edited by: Tom Brown ]
[ November 03, 2003: Message edited by: Tom Brown ]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic