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 wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

parent.frame.document problems 1

Status
Not open for further replies.

skills

Programmer
Jun 24, 2003
60
US
I have a problem with using parent.frame.document in my code.

I have multiple instances of parent.frame.document to change a frame url being performed in a row. The frame that is being changed is hidden. My problem is that only the last parent.frame.document of a selected group will actually work.

Any suggestions on possible solutions would be greatly appreciated.

Thanks,

Jonathan Hubacher
 
Like you said before, I need to have it so that I get out of submitparams. Once I am out of submitparams, the page loads. Here is my problem. All javascript needs to be in a function. The only way it will load is if it the function that called it, and all the other functions used to call it are closed. Now comes the problem. I have a form. The only way the input and checkbox variables can be seen is if I send them to a function, (submitparams). I don't see anyway of getting around that. And the only way to have a page load in another frame is to get out of that function. My second problem is that I have another url change buried in search, and that doesn't get done because the first doesn't get done. Are you sure there is no other way of reloading a frame without getting out of the function. This is the only way I see that would work.

Jonathan
 
alright, here's how i solved it: note that these are test pages, so you will have to modify them slightly to your needs.

mainpage: this file contains a new version of submitparams(), a new version of compare(), a new function continueSearch() and a changed form "onsubmit". you will need to fill in your functions turnallboxoff() and checkall(). you will also need to complete the table of checkboxes and update the form onsubmit accordingly. the order in onsubmit is irrelevant; just make sure that the checkbox name matches the filename to search (e.g. CSSC - cssc.htm)

<!DOCTYPE HTML PUBLIC &quot;-//W3C//DTD HTML 4.01 Transitional//EN&quot;>
<html>
<head>
<title>test</title>
<script type=&quot;text/javascript&quot;>
function submitparams(input, arParams) {
if (!arParams || !arParams.length || arParams.length == 0) {
if (!self.arMatches) {
alert(self.input + &quot; not found.&quot;);
}
else alert(arMatches.join(&quot;\n&quot;));
self.arMatches = null;
return true;
}
else {
if (!arParams[0].checked) {
arParams.shift();
submitparams(input, arParams);
}
else {
search(arParams[0].name + &quot;.htm&quot;, input);
}
}
self.input = input;
self.arParams = arParams;
}

function continueSearch() {
self.arParams.shift();
submitparams(self.input, self.arParams);
}

function search(file, query) {
var iframe = document.getElementById(&quot;iframe&quot;);
iframe.src = file;
}

function compare(oLink, sInput, sFile) {
var re = new RegExp(sInput, &quot;gi&quot;);

if (re.test(oLink.innerHTML)) {
self.arMatches = self.arMatches ? self.arMatches : [];
arMatches.push(&quot;\&quot;&quot; + sInput + &quot;\&quot; found in \&quot;&quot; +
oLink.innerHTML + &quot;\&quot; in &quot; + sFile);
}
return true;
}

function turnallboxoff() {

}

function checkall() {

}

</script>
</head>

<body>
<FORM name = &quot;drawing_finder&quot;
onSubmit=&quot;submitparams(this.subject.value,
[this.ESO,
this.CS2,
this.CSSC,
this.GWC,
this.HF,
this.MICC,
this.ALL]);return false;&quot;>
<B>SUBJECT: </B> <INPUT TYPE = &quot;text&quot; NAME = &quot;subject&quot; SIZE = &quot;40&quot;> <INPUT TYPE = &quot;submit&quot; value = &quot;Search&quot;>
<BR><BR>

<TABLE>
<TR>
<TD>
<B>SEARCH ONLY:</B>
</TD>
<TD>
<INPUT TYPE = &quot;checkbox&quot; NAME = &quot;CS2&quot; onClick=&quot;turnallboxoff();&quot;> CS2
</TD>
<TD>
<INPUT TYPE = &quot;checkbox&quot; NAME = &quot;CSSC&quot; onClick=&quot;turnallboxoff();&quot;> CSSC
</TD>
<TD>
<INPUT TYPE = &quot;checkbox&quot; NAME = &quot;ESO&quot; onClick=&quot;turnallboxoff();&quot;> ESO
</TD>
<TD>
<INPUT TYPE = &quot;checkbox&quot; NAME = &quot;GWC&quot; onClick=&quot;turnallboxoff();&quot;> GWC
</TD>
<TD>
<INPUT TYPE = &quot;checkbox&quot; NAME = &quot;HF&quot; onClick=&quot;turnallboxoff();&quot;> HF
</TD>
<TD>
<INPUT TYPE = &quot;checkbox&quot; NAME = &quot;MICC&quot; onClick=&quot;turnallboxoff();&quot;> MICC
</TD>
</TR>
<TR>
<TD></TD>
<TD>
<INPUT TYPE = &quot;checkbox&quot; NAME = &quot;ALL&quot; onClick=&quot;checkall();&quot;> ALL
</TD>
</TR>
</TABLE>
</FORM>
<p/>
<iframe id=&quot;iframe&quot; style=&quot;display:none;&quot;></iframe>
</body>
</html>

search pages: onload, your search pages will need to call parent.compare() on all of the links, then parent.continueSearch().

<html>
<head>
<title></title>
<script type=&quot;text/javascript&quot;>
window.onload = function() {
for (var x = 0; x < document.links.length; x++) {
parent.compare(document.links[x], parent.input, document.location);
}

parent.continueSearch();
}
</script>
</head>

<body>
<form>
cssc.htm
<br/>
<a href=&quot;dogs.html&quot;>dogs</a>
<br/>
<a href=&quot;cats.html&quot;>cats</a>
</form>
</body>
</html>




also note that this method uses a hidden iframe to load the document, which then calls the parent's functions to do the work.

type in &quot;dog&quot;, check &quot;cssc&quot; and click Search

i hope this gives you some ideas...



=========================================================
try { succeed(); } catch(E) { tryAgain(); }
-jeff
 
Well,

I decided to scrap what I had for the subdivision thing and made it so that my one page has 58 frames in it. Crazy I know, but only 2 show. Theoretically, this will work. My problem is that I get this error: parent.cs2_x.document is null or not an object.

The names are all correct, including the case.

What could be my other problems?

Jonathan
 
Here is my new code

function submitparams(input, CS2, CSSC, ESO, GWC, HF, MICC, NWT, OIS, PCS, PIC, PRS, SCS)
{
if (CS2 == true)
{
var z=0;
while (z < parent.cs2_x.document.links.length)
{
var pdf_link = parent.cs2_x.document.links[z];
var pdf_link_text = parent.cs2_x.document.links[z].innerHTML;
compare(pdf_link,pdf_link_text,input)
}
z=0;
while (z < parent.cs2_1.document.links.length)
{
var pdf_link = parent.cs2_1.document.links[z];
var pdf_link_text = parent.cs2_1.document.links[z].innerHTML;
compare(pdf_link,pdf_link_text,input)
}
 
and here is the rest.

<HTML>
<HEAD>
</HEAD>
<FRAMESET rows=&quot;62%,38%,*&quot;>
<frame src=&quot;search.htm&quot; name=&quot;search&quot; scrolling=&quot;no&quot; noresize>
<frame src=&quot;results.htm&quot; name=&quot;results&quot; scrolling=&quot;auto&quot;>
<frame src=&quot;hiddenpage.htm&quot; name=&quot;scroller&quot;>
<frame src=&quot;cs2_x.htm&quot; name=&quot;cs2_x&quot;>
<frame src=&quot;cs2_1.htm&quot; name=&quot;cs2_1&quot;>
<frame src=&quot;cs2_2.htm&quot; name=&quot;cs2_2&quot;>
<frame src=&quot;cs2_3.htm&quot; name=&quot;cs2_3&quot;>
<frame src=&quot;cs2_4.htm&quot; name=&quot;cs2_4&quot;>
....

the compare functionis still the same
 
Actually, i changed something, and I got rod of the error. The problem is now that it takes up 100% of my memory and freezes the browser. So, this obviosuly won't work either. I am looking to go back to my very very first method which was windows, opening and closing. I am hoping you can maybe fix my original problem. I had the window sized 1 x 1, because I could not get it any smaller. This is still a big enough size for a window that if you saw it flash on your screen fast it gets aggrevating. I have the window go to blur as soon as it is opened, and close it as soon as it is done. Is it possible to make a smaller window, something that is only a pixel x pixel worth or so. If so, that would solve my problem.


Jonathan
 
skills,

try out my post with the hidden iframe first...use the sample main page and cssc.htm, type in &quot;dog&quot;, check the &quot;cssc&quot; box and click Search.

regarding windows smaller than 1x1, most if not all browsers will not allow a window to be created smaller than about 100x100 in my experience. no way to make a hidden window - this could be considered a security risk. IE will currently allow you to open windows offscreen though (top = -1000, left=-1000 or so)



=========================================================
try { succeed(); } catch(E) { tryAgain(); }
-jeff
 
Jeff,

Sorry it took so long for me to get back to you, but I got sidetracked. Please take a look at this posting.

&quot;search engine coming up with random results&quot;

It is my latest posting, and has to do with this. I now have the window go off the screen, and it works great. My only problem that I have now is that the total number of results is random. One time the total results will be something like 8, and the next time they will be 5, and then 2 and then 6, etc. And then when I try looking a smaller area, it gives me an random number within the first 5 tries or so, and the next 25+ are fine. Take a look at my new posting for the code. I am sure it is something small to fix.

Thanks,

Jonathan Hubacher
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top