JavaScript - Webhelp Navigation When Link From Right Frame Clicked
I have a WebHelp framework created by chmProcessor whereby index.htm calls frameset.html that references a left frame "treeFrame" and right frame "frameCont". The treeFrame has javascript to change the icons from selected to not selected and high light the selected topic.
I have a need to have links in the right frame. And when I click on the link in the right frame, I want the right frame to display the topic but I also want the treeFrame navigation to open the navigation to the newly selected topic. How would I go about implementing this? In the tree.html, the tree navigation gets created with this code: Code: contentTree.create( document.getElementById( "contentsTree" ) , window.parent.document.getElementById( "frameCont" ) , window.parent.parent.location.href ); Here is the tree.js Code: /************************************ (C) Toni Bennasar 2007 http://chmprocessor.sf.net Under GPL license. Functions to create a content tree for many web pages. *************************************/ var contentTree = new Object(); contentTree.pageloaded = function() { // Get the title of the loaded page: pageRelativeUrl = getPageTitle( contentTree.frame.contentWindow.document.location.href ) // Search the link to this page node = contentTree.seachLinkByHref( pageRelativeUrl ); if( node == "" ) { // Try to search by the page title, without internal reference: idx = pageRelativeUrl.indexOf( "#" ) if( idx >= 0 ) pageRelativeUrl = pageRelativeUrl.substring( 0 , idx ); node = contentTree.seachLinkByFileTitle( pageRelativeUrl ); } if( node != "" ) { // If its found, select it over the tree: contentTree.selectLink( node , true , false ); } } // Initializes the tree. // tree : UL element that contains the tree // frame: The frame that will contain the topic pages. // url: Input URL of the page. contentTree.create = function( tree , contentFrame , url ) { // Store ref to tree elements: contentTree.frame = contentFrame; contentTree.tree = tree; contentTree.selectedLink = ""; // Change the links to open his ref into the iframe contentTree.links = tree.getElementsByTagName("a"); // Create click events for the links: for (var i=0; i<contentTree.links.length; i++) { contentTree.links[i].onclick = function(e){ contentTree.frame.src = this.href; contentTree.selectLink( this , false , true ); //e.stopPropagation(); stopEvent(e); return false; } } // Prepare all the submenus var submenus = tree.getElementsByTagName("ul"); for( var i=0; i< submenus.length; i++ ) { var sb = submenus[i]; sb.parentNode.className="submenu"; sb.setAttribute("status", "closed"); // click open the submenu: sb.parentNode.onclick = function(e) { var ulChild=this.getElementsByTagName("ul")[0]; if( ulChild.getAttribute("status") == "closed" ) { contentTree.openUlElement( ulChild ); } else if( ulChild.getAttribute("status") == "open" ) { ulChild.style.display="none"; ulChild.setAttribute("status", "closed"); this.style.backgroundImage="url(1g.gif)"; } //e.stopPropagation(); stopEvent(e); } // To avoid events when the submenu items are pressed. sb.onclick=function(e){ //e.stopPropagation(); stopEvent(e); } } // Load the default page, or the selected topic page: var topic = getURLParam( url , "topic"); var topicLink = ""; if( topic != "" ) topicLink = contentTree.seachLinkByTitle( topic ); if( topicLink != "" ) contentTree.selectLink( topicLink , true , true ); else if( contentTree.links.length > 0 ) contentTree.selectLink( contentTree.links[0] , true , true ); // When an internal link is clicked follow the selection at the tree: contentFrame.onload_1 = function(){ contentTree.pageloaded(); } } contentTree.openUlElement = function( ulElement ) { if( ulElement.getAttribute("status") == "closed" ) { ulElement.style.display="block"; ulElement.setAttribute("status", "open"); ulElement.parentNode.style.backgroundImage="url(2g.gif)"; } } contentTree.selectUrl = function( url ) { var lnk = contentTree.seachLinkByHref( url ); if( lnk == "" ) // URL not found contentTree.frame.src = url else contentTree.selectLink( lnk , true , true ); } contentTree.selectLink = function( lnkObject , expandTree , loadContentFrame ) { if( contentTree.selectedLink != "" ) contentTree.selectedLink.style.backgroundColor = contentTree.notSelectedBg ; else contentTree.notSelectedBg = lnkObject.style.backgroundColor; if( loadContentFrame ) contentTree.frame.src = lnkObject.href; contentTree.selectedLink = lnkObject; lnkObject.style.backgroundColor = "#33CC66" ; if( expandTree ) { var ulElement = lnkObject.parentNode.parentNode; while( ulElement != contentTree.tree ) { contentTree.openUlElement( ulElement ); ulElement = ulElement.parentNode.parentNode; } } } // Search a link into the tree by his text: contentTree.seachLinkByTitle = function( strTitle ) { var strTitleLower = strTitle.toLowerCase() for (var i=0; i<contentTree.links.length; i++) { // Get the text of the link, without return carriages var linkText = contentTree.links[i].innerHTML.toLowerCase(); linkText = linkText.replace(/\n/," "); linkText = linkText.replace(/\r/,""); if( linkText == strTitleLower ) return contentTree.links[i]; } return ""; } // Search a link into the tree by his href: contentTree.seachLinkByHref = function( strHref ) { for (var i=0; i<contentTree.links.length; i++) { //var aux = unescape( contentTree.links[i].href ); var aux = contentTree.links[i].href; if( aux == strHref || endsWith( aux , "/" + strHref ) ) return contentTree.links[i]; } return ""; } contentTree.seachLinkByFileTitle = function( strFile ) { for (var i=0; i<contentTree.links.length; i++) { //var aux = getPageTitle( unescape( contentTree.links[i].href ) ); var aux = getPageTitle( contentTree.links[i].href ); if( aux == strFile ) return contentTree.links[i]; else { idx = aux.indexOf( "#" ) if( idx >= 0 ) { aux = aux.substring( 0 , idx ); if( aux == strFile ) return contentTree.links[i]; } } } return ""; } // Search links that contains contentTree.searchByContent = function( strSearch , idList , idTopicsList ) { var list = document.getElementById( idList ); list.options.length=0; if( strSearch == "" ) return; var topicsList = document.getElementById( idTopicsList ); //var strLower = strSearch.toLowerCase(); var strLower = normalizeString( strSearch ); for (var i=0; i<topicsList.options.length; i++) { if( normalizeString( topicsList.options[i].text ).indexOf( strLower ) >= 0 ) { var opt = new Option( topicsList.options[i].text ); opt.value = topicsList.options[i].value ; list.options[ list.options.length ] = opt; } } list.ondblclick = function(e) { if( list.selectedIndex >= 0 ) contentTree.selectUrl( list.options[ list.selectedIndex ].value ); } } Similar TutorialsHello all! I'm having a bit of an issue here with my lastest project. What I'm trying to do is have a menu that a user would click one of two links which would change the targeted iFrame, then repeat for two more options, and again for two more. It is essentially a filtering system for videos (the best way for you to see what I mean is to check out http://grph.cmwdesign.ca). My actual issue here is the changing of the iframe href, and on top of that, I seem to not to be able to properly get my functions to run all the time. Here is my Javascript: Code: var categoryLink=new Array(); var counter; var link = ""; categoryLink[0] = ""; categoryLink[1] = ""; categoryLink[2] = ""; counter = "0"; $(document).ready(function() { $(".atonal").live('click', function() { { alert("sometext"); if (categoryLink[0]=="") { categoryLink[0] = "atonal"; $("a.frame").attr('href', categoryLink[0] + categoryLink[1] + categoryLink[2]); else { categoryLink[0] = ""; $("a.frame").attr('href', categoryLink[0] + categoryLink[1] + categoryLink[2]); } }); }); $(document).ready(function() { $(".tonal").live('click', function() { alert("sometext"); if (categoryLink[0]=="") { categoryLink[0] = "tonal"; $("a.frame").attr('href', categoryLink[0] + categoryLink[1] + categoryLink[2]); else { categoryLink[0] = ""; $("a.frame").attr('href', categoryLink[0] + categoryLink[1] + categoryLink[2]); } }); }); $(document).ready(function() { $(".being").live('click', function() { alert("sometext"); categoryLink[1] = "being"; $("a.frame").attr('href', categoryLink[0] + categoryLink[1] + categoryLink[2]); if (categoryLink[1]=="") { categoryLink[1] = "being"; $("a.frame").attr('href', categoryLink[0] + categoryLink[1] + categoryLink[2]); else { categoryLink[1] = ""; $("a.frame").attr('href', categoryLink[0] + categoryLink[1] + categoryLink[2]); } }); }); $(document).ready(function() { $(".doing").live('click', function() { alert("sometext"); if (categoryLink[1]=="") { categoryLink[1] = "doing"; $("a.frame").attr('href', categoryLink[0] + categoryLink[1] + categoryLink[2]); else { categoryLink[1] = ""; $("a.frame").attr('href', categoryLink[0] + categoryLink[1] + categoryLink[2]); } }); }); $(document).ready(function() { $(".abstract").live('click', function() { alert("sometext"); if (categoryLink[2]=="") { categoryLink[2] = "abstract"; $("a.frame").attr('href', categoryLink[0] + categoryLink[1] + categoryLink[2]); else { categoryLink[2] = ""; $("a.frame").attr('href', categoryLink[0] + categoryLink[1] + categoryLink[2]); } }); }); $(document).ready(function() { $(".documentary").live('click', function() { alert("sometext"); if (categoryLink[2]=="") { categoryLink[2] = "documentary"; $("a.frame").attr('href', categoryLink[0] + categoryLink[1] + categoryLink[2]); else { categoryLink[2] = ""; $("a.frame").attr('href', categoryLink[0] + categoryLink[1] + categoryLink[2]); } }); }); and the HTML in question: Code: <table> <tr> <td height="35" width="210" valign="top">choose your sound</td> <td width="165" valign="top"><a href="#" id="atonal">atonal sounds</a></td> <td width="165" valign="top"><a href="#" id="tonal">tonal sounds</a></td> </tr> <tr> <td height="35" width="210" valign="top">choose your text</td> <td width="165" valign="top"><a href="#" id="being">being words</a></td> <td width="165" valign="top"><a href="#" id="doing">doing words</td> </tr> <tr> <td height="35" width="210" valign="top">choose your image</td> <td width="165" valign="top"><a href="#" id="abstract">abstract images</a></td> <td width="165" valign="top"><a href="#" id="documentary">documentary images</a></td> </tr> </table> I'm no Javascript wiz, so I'm sure I'm probably not going about this entirely the correct way. Any suggestions would be great! Hi everyone! I need a little help with something. I have a page with several links that when clicked open a modal window. The same window for each link, with a form. However inside the form I need to print the id of the link that was clicked. Like so: <a href="#" id="1">Link 1</a> <a href="#" id="2">Link 2</a> <a href="#" id="3">Link 3</a> <form> ....somehow print/echo the id of the link... </form> Is this possible? Does anyone know how to do that? I'd appreciate any help! Sorry I am new to JavaScript. Says that a.html has two same anchor links (<a href="b.html">b</a>). The anchor links are uneditable but we could add JavaScript to the a.html. Except for dynamic adding onclick event, any other ways could get to know which anchor link being clicked? I have no clue if this is in the correct forum but.... is there a way to determine whether a user clicked on a link vs typed in the url to get to a page? I'm trying to stop users from messing with GET forms (and i have to use them, POST wouldn't make sense in this case). Thanks Hello I need to not publicly display phone number inside my website page (I use Joomla CMS). In fact the main goal is of course to be able to show the number but not to be crawled by search engine.. So in practice instead to see this: Phone: 013456789 I would like to see this: Phone: Click here for see the number By clicking on that link the number must be displayed... My website for display the phone field use this php code: Code: <?php echo $CustomFields->field('my_phone',$listing); ?> I asked in some forum and some people tell me is possible to customize this php code with javascript for let me hide/show the field value but I don't have a single idea how to do this because I'm not a programmer... I take a look in all javascript libraries but I don't find any javacript ready for use for let me implement it inside the php code... Anybody have a suggestion please ? many thank Hey all, Hoping someone could help me out with some javascript coding as I am a complete novice to this! I am currently building a website using 1 static page and all the content will be pulled in through different iframes by clicking on a navigation on the page. I found a very handy piece of javascript coding that lets me remove a class from one link and move it to the link that was clicked on (the code will be below). The issue I am facing with this is that if I have Home set to class="On" to begin with and then click on Location, the background image will be added to the Location section but won't get removed from Home until it is physically clicked on. Can anyone help me out with how I can get this to work correctly? javascript: Code: <script language="JavaScript" type="text/javascript"> var Lst; function CngClass(obj){ if (typeof(obj)=='string') obj=document.getElementById(obj); if (Lst) Lst.className=''; obj.className='On'; Lst=obj; } </script> HTML: Code: <div id="navWrapper"> <div id="globalNav"> <ul> <li onclick="CngClass(this);" class="On"><a href="iframes/home.html" target="content_iframe">Home</a></li> <li onclick="CngClass(this);" class=""><a href="iframes/location.html" target="content_iframe">Location</a></li> <li onclick="CngClass(this);" class=""><a href="iframes/speakers.html" target="content_iframe">Speakers</a></li> <li onclick="CngClass(this);" class=""><a href="iframes/agenda.html" target="content_iframe">Agenda</a></li> <li onclick="CngClass(this);" class=""><a href="iframes/useful_material.html" target="content_iframe">Useful Material</a></li> <li onclick="CngClass(this);" class=""><a href="iframes/event_presentations.html" target="content_iframe">Event Presentations</a></li> <li onclick="CngClass(this);" class=""><a href="iframes/gallery.html" target="content_iframe">Gallery</a></li> </ul> </div> <div id="localNav"></div> </div> Hi guys, I've been breaking my brains for few hours, I already searched online and I found nothing so far. What I wanna do.... I have 5 different images linked to 5 different websites. Once the image is clicked, the first link will be displayed in an iframe, and the image will change to the second one. Once we click on the second image, the second link will be displayed using the same iframe, and so on. The code changes the images,but I dunno how to deal with the link to the websites. This is the code: Code: <html> <head> <title>Testing...</title> </head> <script type="text/javascript"> imgs=Array("1.png","2.png","3.png","4.png","5.png"); links=Array("www.vbct.ca","www.cnn.com","www.castanet.net","www.yahoo.com","www.cubaweb.cu"); var x=0; function change() { document.getElementById("changes").src=imgs[++x]; if (x==4) { x=-1; } } if (!imgs[x+1]) { x=-1; } </script> <body> <div> <iframe src="http://www.vbct.ca" style="border: 0; position:relative; top:0; left:0; right:0; bottom:0; width:100%; height:400px;" name="page" width="100%"></iframe> </div> <br /><br /> <div> <a href="#" target="page"><img src="1.png" id="changes" alt="alttext" onmousedown="change()" style="cursor: pointer;" /></a> </div> </body> </html> And this is the link to the test page: http://www.virtualbc.ca/sites/test/ Please help me make the links below open in the "top" or "parent" frame of a window. For example, in HTML, you would use
Code: <a href="URL" target="_top">LINK</a> I just do not know how to make the links below perform in the parent window. (or even a new window if that is only possible.) Code: var $el, $tempDiv, $tempButton, divHeight = 0; $.fn.middleBoxButton = function(text, url) { return this.hover(function(e) { $el = $(this).css("border-color", "white"); divHeight = $el.height() + parseInt($el.css("padding-top")) + parseInt($el.css("padding-bottom")); $tempDiv = $("<div />", { "class": "overlay rounded" }); $tempButton = $("<a />", { "href": url, "text": text, "class": "widget-button rounded", "css": { "top": (divHeight / 2) - 7 + "px" } }).appendTo($tempDiv); $tempDiv.appendTo($el); }, function(e) { $el = $(this).css("border-color", "#999"); $(".overlay").fadeOut("fast", function() { $(this).remove(); }) }); } $(function() { $(".widget-one").middleBoxButton("Action Games","action.htm"); $(".widget-two").middleBoxButton("Adventure Games", "adventure.htm"); $(".widget-three").middleBoxButton("Arcade Games", "arcade.htm"); $(".widget-four").middleBoxButton("Puzzle Games", "puzzle.htm"); $(".widget-five").middleBoxButton("Sport Games", "sport.htm"); $(".widget-six").middleBoxButton("Search Games", "searchgames.htm"); }); Thank you very much for your help!!! Code: oaktree.addItem("RC Mail", branch1, "rcmail/") //Add this item to branch2 I can open it up in the current page, but the menu is in a frame and I need to open it in a fram called "home". How can I do that~?? <script language="JavaScript"> function changeColor(cell_id){var state1="#dde6ed"; var state2="#ffc20e"; var cellid = new Array ("id1", "id2", "id3", "id4", "id5", "id6"); for(var i = 0; i < cellid.length; i++){var nav = document.getElementById(cellid[i]); if(cellid == nav.id){nav.style.backgroundColor=state2;} else {nav.style.backgroundColor=state1;}}} </script> Can anyone tell me what is wrong with this script. I put an onClick= changeColor(this);" in my <td> tag to call the script but still not working. Hi. I have a question about java script code. I'm creating a website with frames. Within the main page frame, there are tables in the main content page. When I created the website, it fit perfectly in the browser window of my smaller laptop. I just checked it out on my old G5 and the images/pages are too big and either cut off or scroll bars appear (which is not what I want) So I wanted to know what code I put in my files and where to put it? Also, what pages does it need to be in? the main frame index page? the specific pages that fit within the frames? some are images that load in the frames? would i need to create an .html for those and then have the .jpg load so that it can be resized? I need the main page to be resized to fit the browser as well as the pages in the frames to fit. Can you help? Thanks I' am trying to do a frame by frame animation, lik an animated gif. I am using svg (vector graphics) and IE9 has native support for svg. The code functions in every other browser but IE9 plays the animation once then nothing. If you would like to try and not have svg files you can use whatever gif,jpg or png just put an img-tag where i have embed. Code: <!DOCTYPE HTML> <html> <head> <meta charset="utf-8"> <title>Animation</title> <style type="text/css"> /*One div per image all uses this class*/ .eyesPos { position:absolute; width:80px; height:50px; z-index:1; left: 0px; top: 0px; } #eye_wrapper{/*This is a master div for easy placement of the others*/ position:absolute; width:80px; height:50px; z-index:2; left: 275px; top: 200px; } </style> <script> var eyes=["a","b","c","d"];//Image id in this array var startAnim=setInterval(visaOga,100);//Animation speed function visaOga(){ document.getElementById(eyes.splice(0,1)).style.display="block"; if(eyes.length==0){ document.getElementById("a").style.display="none"; document.getElementById("b").style.display="none"; document.getElementById("c").style.display="none"; dBort = function(){ document.getElementById("d").style.display="none"; eyes=["a","b","c","d"]; } setTimeout(dBort,1500);//So last image is shown 1.5 sec return;//Aborts - dBort -. Sequence can start over if(document.getElementById("d").style.display=="none"){ startAnim;//Strts sequence if last image invisible } } } </script> </head> <body> <!--Images in own div invisible at start--> <div id="eye_wrapper"> <div class="eyesPos" id="a" style= display:none;> <embed src="0.svg" width="80" height="50" /> </div> <div class="eyesPos" id="b" style= display:none;> <embed src="1.svg" width="80" height="50" /> </div> <div class="eyesPos" id="c" style= display:none;> <embed src="2.svg" width="80" height="50" /> </div> <div class="eyesPos" id="d" style= display:none;> <embed src="3.svg" width="80" height="50" /> </div> </div> </body> </html> guys help pls.. i need to pass the data in the textfields from the left frame to the textfields in the right frame of my frameset. (ex: dslnum of frame1 will be pass to txtDSLTN of frame2) frame1: http://www.mediafire.com/?hge1ws29mdhmu7e frame2: http://www.mediafire.com/?k83cb64wbpskw97 thanks in advance! I have a page called answersheet.html which I am popping up using a function called NewWindow; Code: <a href="javascript:myVoid()" onclick="NewWindow('/images/101online/practicetest1/listensubtest1/answersheet.html','PopUp','625','400','no',''); return true;"> It works fine. answersheet.html consists of two frames, the top frame containing a button with onclick="myprint()" to print out the bottom frame: Code: <script type="text/javascript"> function myprint() { window.parent.bottom.focus(); window.print(); } </script> It does the job in Internet Explorer, but Firefox and Chrome only print the top frame with the print button! Is the function myprint() IE only coding? If so, what should I use? Hey, I'm not to good at javascript and need help. When someone clicks an option in a <select> box, I want a field to appear with a normal text box. For example: Code: <!--Option box--> <select name="method"> <option>Post 2 Host</option> <option>Paid</option> <!--I want it when they click Paid, a box shows up below. Such as--> <input type="text" name="paid" /> Can you show me how I can do this? Thanks. Hey, I'm new to javascript and was wondering if there is something where you can tell if something is clicked. All I need is to know something where you click something and it appears, and click again it disappears. How can I do this? Thanks! Hi everyone - I was wondering how it would be possible for me to create a FAQ with drop-down answers when the question is clicked? For example: https://www.facebook.com/help/?page=1145 Facebook has something like that available. Any ideas? On custom button images, how do you give them the effect that they're "pushed" when the user clicks them and "unpushed" when the user lets his finger off the mouse button? I'm guessing it's some type of rollover effect, but I'm not sure how it's done.
I have a simple problem that I can't solve. I know that you guys might know how to solve it. I'm using an extension of dreamweaver called Coursebuilder. I'm making an online-examination to improve education especially in a far region of Asia where there's poor quality of education in there. Now, I'm making a multiplication choice type of exam with radio buttons in it and when the "check answer" was clicked, the answer will be explained. It is already done, but the problem is the feedback score. I can't make a feedback score... example the examination is 40/100 score it must appear on the screen at once after a click of a certain button. That's my only problem for now. It will be used in CD format and online. what should i do? All I need is to know how will I put a button that once it was clicked the score in the examination will appear. I'm an amateur web designer, I need your help. Thanks please help me. Hi, I am currently working on a website with a custom livesearch. The livesearch is a simple <ul> under the input box. I am trying to make it so that if the user click anywhere other than the input box(id=searchInput) or the list(id=searchResults). I tried an onblur on the input box, but when the user clicks on the list it vanishes, which defeats the object! Any help would be much appreciated |