javascript - Search for string in multiple html files with jquery -


I will explain my problem with a few words. I have an HTML with various IORMs, a table of contents in an iframe (TOC) and the content of the related element emerged in the TOC in another subject. There are different TOCs, so that by clicking on a link, we will take on a topic that is related to another TOC, and so I want to reload the TOC frame with the proper TOC. To do this, because in each topic there is a specific ID within the TOC, I search the ID of the subject loaded in the main frame in all the TOCs and when I get the desired TOC, I load it in the TOC frame. I am

The code I have written is so far:

  / * function that is called on the load of each subject - this topic is the unique ID as parameter The names of / html files with varied tox / var tocs = ["toc.htm", "toc_documentazione.htm", "toc_flussiesteri.htm", "toc_garante.htm", "toc_garante.htm", "toc_legittimita" Htm "," toc_normativa.htm "," toc_settori.htm "," toc_sicurezza.htm "," toc_sistemadp.htm "," toc_vistaarticolato.htm "] var i = 0; / * unless you search for a correspondence or someone Do not change until more TOCs * / (when (TOC [i], "a + + id" I + 1;} / * This line is probably wrong, but the idea is to load the TOC mixed in the appropriate frame * / $ (content). Load (tocs) [I - 1] + "#content");} * Returning search results using AJAX to search ID in HTML file passed as function parameter (newToc) // function changeTOC (newToc, id ) {Var found = false; $ (), (html), (html), (html). (Function (temp_toc));}}; / * Other We received false * return / returned; }   

The problem I have with the cycle of the time I search through various TOC files. I have done some debugging and there is no point in the fact that the TOO is searching for the AOD I am in the first position, while 10 chakras are eliminated and only in the last time it tells me to match it The TOC has been found, which is actually the first in the list.

Hope I am able to clarify myself. Thank you for your help

Finally I set it to the right by using the AJAX call with synconus Done I am not posting all code reasons here because it would be confusing, but what I changed in comparison to the code written below is given below and now everything works fine. Maybe it is not optimal in performance, but I am not concerned about this concern, so I am happy with it :) Hope it can help others.

  / * function that is called on the load of each subject - this parameter * / function gets the unique ID as the highlight (id) {var tmpVal = sessionStorage.getItem (' Key '); // We check that there is currently another element in the TOC highlighted in bold, if we remove lockout (tmpVal) {var tmpEle = parent.window.frames [0] .document.getElementById ('a' + TmpVal); If (tmpEle) {tmpEle.className = ''; }} / / Var tocs = ["toc.htm", "toc_documentazione.htm", "toc_flussiesteri.htm", "toc_garantei.htm", "toc_garante.htm", "toc_legittimita", to find the loop with the subject selected through all tos. Htm "" toc_normativa.htm "," toc_settori.htm "," toc_sicurezza.htm "," toc_sistemadp.htm "," toc_vistaarticolato.htm "]; Var i = 0; While (ChangeTOC (Tox [i], "a" + id) and i & lt; tocs.length) {i = i + 1; } // Currently TOC var currentToc = $ ("# toc_iframe", parent.document) is loaded .attr ("src"); Var indexCurrentTOC = tocs.indexOf (currentToc); // We check that Mailing TOC is the current one, if so, we do not change anything (! (ChangeCOCTOC [Index CurrentTOC], "a" + id)) {$ ("# toc_iframe", parent.document). Attr ("src", TOCs [i]); } Var myElt = parent.window.frames [0] .document.getElementById ('a' + ID); // Highlight the current element in TOE myElt.focus (); MyElt.className + = 'active'; ScrollTo (myElt.offsetLeft-48, myElt.offsetTop- (parent.document.body.clientHyight / 3)); SessionStorage.setItem ("key", id); } // New Talk Function changeTOC (newToc, id) in the Toss file for element with AOC {var found = false; $ Ajax ({url: newToc, async: false, context: document.body}) done (function (temp_toc) {if (temp_toc.indexOf (id)! = - 1) {found = true;}}); Returns found;   

}

Comments

Popular posts from this blog

php - PDO bindParam() fatal error -

logging - How can I log both the Request.InputStream and Response.OutputStream traffic in my ASP.NET MVC3 Application for specific Actions? -

java - Why my included JSP file won't get processed correctly? -