Jump to content
  • 0

Вывод результата поиска в фрейм


mexkb
 Share

Question

Доброго всем времени суток. Занимаюсь созданием информационной системы и появилась необходимость организовать в ней поиск. В общем то с поиском справился, а вот с выводами результатов поиска справится никак не получается.

win = document.open(document.location,document.title,"");

Как прописать конструкцию что бы вывод результатов был в фрейм, а не в всплывающее окно? Пробовал top.frames, self.top.frames, location и много других вариантов - не дают результата. Строка поиска находится в одном фрейме, а вывод результата поисков требуется в другом.

<html>
<head>
<title></title>

<link rel="stylesheet" type="text/css" href="style.css"/>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">

<!-- HEAD START HERE -->

<script LANGUAGE="JavaScript">

<!-- Begin
var item = new Array();

/* Here is where all the magic happens.
Just enter as many additional pages that
that you want to search, then fill in the
additional listings for each page.
*/

// "Page Name","path","Page Title","Many,Key,Words","Descriptive Comments"

c=0; item[c]=new Array("123.html","123","123","123","123");
c++; item[c]=new Array("234.html","243","234","234","234");

page="<html><head><title>Search Results</title></head><body bgcolor='white'><center><table border=0 cellspacing=10 width=80%>";

function search(frm) {
win = window.open("","","scrollbars");
win.document.write(page);
txt = frm.srchval.value.split(" ");
fnd = new Array(); total=0;
for (i = 0; i < item.length; i++) {
fnd[i] = 0; order = new Array(0, 4, 2, 3);
for (j = 0; j < order.length; j++)
for (k = 0; k < txt.length; k++)
if (item[i][order[j]].toLowerCase().indexOf(txt[k]) > -1 && txt[k] != "")
fnd[i] += (j+1);
}
for (i = 0; i < fnd.length; i++) {
n = 0; w = -1;
for (j = 0;j < fnd.length; j++)
if (fnd[j] > n) { n = fnd[j]; w = j; };
if (w > -1) total += show(w, win, n);
fnd[w] = 0;
}
win.document.write("</table><br>Total found: "+total+"<br></body></html>");
win.document.close();
}
function show(which,wind,num) {
link = item[which][1] + item[which][0];
line = "<tr><td><a href='"+link+"'>"+item[which][2]+"</a> Score: "+num+"<br>";
line += item[which][4] + "<br>"+link+"</td></tr>";
wind.document.write(line);
return 1;
}
// End -->
</script>

<!-- HEAD END HERE -->

</head>
<body bgcolor="#EDEDED" text="#000000" link="#000000" topmargin="0" leftmargin="0">
<center>

<!-- BODY START HERE -->

<form method=get action="java script:void(0)" onsubmit="search(this); return false;">
<tr><td><input type=text name=srchval value=""><input type=submit value="Search"></td></tr>
</form>

<!-- BODY END HERE -->

</body>
</html>

Edited by mexkb
Link to comment
Share on other sites

9 answers to this question

Recommended Posts

  • 0
Страница разметки сама всмысле? Она не принципиальна, пусть будет любая, в одном фрейме будет указаный код подгружатсья, в другой будет выводить результат.

Тогда, наверное,

parent.frames[1]

Link to comment
Share on other sites

  • 0
Тогда, наверное,

parent.frames[1]

При использовании top.frames или parent.frames на индекс 1 открывает в том же окне, на любую другую цифру повисает, я так уже пробовал =( Объединяя 2 строчки:

win = top.frames[1].document.write(page);

Показывает результат в том же окне, любое другое число висит.

Edited by mexkb
Link to comment
Share on other sites

  • 0
А [0] ?

Аналогично висит, только [1] канает )

Упдате:

Точнее даже так - при загрузке страницы заного вообще не пашет никак, если не перегружать а просто обновление страницы делать поменяв индекс то будет показывать внутри себя.

Упдате2:

Вообшем то после загрузки страницы при поиске зависает. При обновлении страницы показывает результат, но только в том же фрейме где нажимали на поиск.

Edited by mexkb
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue. See more about our Guidelines and Privacy Policy