JavaScript - Can't Set The Onclick Target
Hey guys,
I'm trying to obtain the object of the element on the page that is clicked, but my code is unable to set the target. Here's what I have. The JavaScript Code: function show_info(e){ //get the targeted element. var targ; if (!e) var e = window.event; if (e.target) targ = e.target; else if (e.srcElement) targ = e.srcElement; if (targ.nodeType == 3) targ = targ.parentNode; alert (targ); //FAIL! } The Form Code: <form action="#" method="post"> <input type="hidden" name\"id" value="" /> <input type="submit" name="submit" value="Info" onclick="show_info()"/> </form> What I want to do is get the target element(the submit button) so that I can get its sibling(it contains a unique ID). But it's not working. Similar TutorialsI've been doing some searching and I can't seem to find what I am looking for. I hope someone can help. I am trying to target a link to an iframe window. The catch is that I need to use an onClick function in a TD tag... Here is an example: <TABLE HEIGHT="40" WIDTH="780" CELLSPACING="0" CELLPADDING="0" BORDER="1"> <TBODY> <TR> <TD ALIGN="CENTER">HEADER 1</TD> </TR> <TR> <TD OnClick="location='http://www.ophil.com'" BGCOLOR="#FFFFFF">Ophil</TD> </TR> </TBODY> </TABLE> </TD> </TR> <table width="100%" border="0" cellspacing="0" cellpadding="1"> <tr> <td><a name="bidframe"> <IFRAME SRC="bid_item_instructions.html" TITLE="IFRAME" SCROLLING="no" NAME="bidpage" WIDTH="100%" HEIGHT="450" ALIGN="center" FRAMEBORDER="yes" > </IFRAME> </a></td> </tr> </table> </CENTER> </BODY> </HTML> I need the results of that onclick to appear in the iframe window I have called bidframe... Any ideas? I'm currently working on a project and I am doing a bunch of image switching. I'm having a problem with the following... I have seven medium image objects and one small one. One is at the top and the other 7 are below. When one of the 7 is clicked, it then becomes the one up top and the one up top then takes the place of the image clicked. This needs to be able to happen no matter which of the seven i click. Also when you click one of the seven it runs a script to change 9 other images in the center of the page. this isnt too important because i have it working already. What i have is, each of the seven images run their function that changes the 9 center images and then it runs another function. What i need is for that function to determine which company for example(shaws, lowes, target) the top image belongs to and replace the image that was clicked with the top one. But i also need to replace the NAME="" and ONCLICK="function()" with the proper ones for the original company up top. Please if you can understand what im trying to do let me know, if you need further clarification i can do so. i can draw a picture of what im trying to do or the layout if needed but i cant necessarily show anyone the project due to a non-disclosure. tested this only on FF. Code: target = this.parentNode.parentNode.getElementsByClassName('help')[0]; target.style.display = (target.style.display=='none')?'inline':'none'; -->Error: target.style is undefined In next two codes what is red is different, all the rest as above. Code: var target = this.parentNode.parentNode.getElementsByClassName('help')[0]; target.style.display = (target.style.display=='none')?'inline':'none'; --> works. Code: xxx = this.parentNode.parentNode.getElementsByClassName('help')[0]; xxx .style.display = ( xxx .style.display=='none')?'inline':'none'; --> works. Why is that ? Hi guys I was wondering if its possible in javascript to do something like this: Code: document.getElementById('div').children('img').style This is my code with int value I can target children is this also possible with a string like img? Code: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" dir="ltr" lang="en-gb" xml:lang="en-gb"> <head> <meta http-equiv="content-type" content="text/html; charset=UTF-8" /> <script type="text/javascript"> window.onload=function() { var d = document; var e = d.getElementById('t'); e.children[0].style.border = "solid black 1px"; } </script> </head> <body> <div id="t"> <img width="120" height="80" src="./images/full6.jpg" alt="" /> <img width="120" height="80" src="./images/full6.jpg" alt="" /> <img width="120" height="80" src="./images/full6.jpg" alt="" /> <img width="120" height="80" src="./images/full6.jpg" alt="" /> </div> </body> </html> Hoping someone can help a simple soul!! I am trying to work out if there is a way that I can use a target url as a simple password (or even username) at a log in screen. Essentially I want to be able to send people to a different URL depending on their login details but without having to do anything too complicated or secure. Hoping someone can help Thanks in advance! I have a few banners and forms that I wish to open in a new tab not the same window or a new window. I have tried the deprecated Code: target="_blank" but even that opens a new window. I have done some research on google and came up with CSS code: Code: form[target] { target-name: new; target-new: tab; } a[target] { target-name: new; target-new: tab; } This however does not work and opens in the same window. When using the CSS I remove the inline target. Any Ideas on how to fix this? Need help adding var target to this form action Would This be correct? var form = inp.form; form.target = "_self"; Code: <html> </head> <script type="text/javascript"> function formop(inp,op) { var form = inp.form; form.action = op + ".php"; var temp = inp.id.split(","); form.id.value = temp[0]; form.FirstName.value = temp[1]; form.LastName.value = temp[2]; } </script> </head> <body> <form method="post"> <input type="hidden" name="id"> <input type="hidden" name="FirstName"> <input type="hidden" name="LastName"> <input type='image' id='show,me,data' onclick=formop(this,'add'); src='static/icon16/add.jpg'> <input type='image' id='show,me,data' onclick=formop(this,'edit'); src='static/icon16/edit.jpg'> <input type='image' id='show,me,data' onclick=formop(this,'delete'); src='static/icon16/delete.jpg'> </form> </body> Is it possible disable an onclick after clicking it and then enable it from another onclick by id Code: <img id="one" href="images/homepage/sliders/bonus_button.jpg" style="position:relative; top:30px; left:50px; height:30px; width:70px; float:left;"> This code runs when it is clicked: Code: $("#one").click(function() { runEffectB(); return false; }); What I would like to happen is for either runEffectB() to not run if it was just run or to disable the #one.click once it has run. I am assuming I will be able to re-enable it from another onclick running a similar function. This is jquery and jquery ui if that helps. Any ideas much appreciated. I have a php page which uses the following javascript code to open another page (The users profile page) and alos carry over the userID (dUid) Code: var userProfileUrl = chatProfileUrl+dUid.replace(/_/gi,""); document.getElementById('userdetails').innerHTML += "<span class='userinfo' onClick=\"window.open('"+userProfileUrl+"','"+dUid+"')\"><img id='profile' style='cursor:pointer;vertical-align:middle;padding-top:4px;' src=images/zoom.png> View Profile</span></br>"; I wanted to add to the menu another image link so I copied the same coding, but I do not know where to place the URL target that I want opened. I know I want the userID (dUid) also to follow this link as well. If I want the coding below to act in the same manner as the coding above, but instead open a page called /gift.php, where do I set the Url? Code: document.getElementById('userdetails').innerHTML += "<span class='userinfo' onClick=\"window.open('"+userProfileUrl+"','"+dUid+"')\"><img id='profile' style='cursor:pointer;vertical-align:middle;padding-top:4px;' src=images/gift.png> Send Gift</span></br>"; Anyone familiar enough with pikachoose to help me out here? Using a pikachoose slideshow inside an iframe and for some reason adding a url target of _top or _parent is not working. It just opens up the link in the iframe window no matter what i do. Anyone with an idea of how to fix this? I'm working on it in the staging area of my site- http://staging.susanb.com/ You can see when you click on one of the images it doesnt fill the entire window This just creeped up on me at the end of a project so im hoping its not a deal breaker thanks in advance!! I have an ajax tabbed site which loads the content in the div below it. I made a drop down link so that the user could select one of 3 on one tab but this is outside of the script.js. I'm wondering if there's a way to get the target of these drop down links to open in the div below instead of a new tab? http://voiceprocess.net/script.js <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Home Improvement Survey Process</title> <link href="../../../voiceprocess.ico" rel="shortcut Icon"> <link rel="stylesheet" type="text/css" href="../styles.css" /> <link href="../dropdown.css" rel="stylesheet" type="text/css" /> <script type="text/javascript" src="jquery.min.js"></script> <script type="text/javascript" src="script.js"></script> </head> <body> <div id="main" style="float:left"> <table width="991" border="0" cellpadding="0"> <tr> <td width="649"><ul class="tabContainer"> <!-- The jQuery generated tabs go here --> </ul></td> <td width="75" style="padding-bottom:43px"> <div id="centeredmenu" style=" width:0px; height:0px"> <ul > <li style="padding-left:0px"><span class="sears"><a href="#')"> </a></span> <ul style="padding-top:2px"> <span class="space"></span><span class="space"></span> <li><a href="pages/sears_refacing.html" target="_self">Cabinets Refacing</a> <div> <li><a href="pages/sears_hvac.html">HVAC </a></li> <li><a href="pages/sears_windows.html"></a>New Windows </a></li> </ul> </li> </div></td> <td width="241"><a href="upsell.php" target="_blank"><img src="../u.png" alt="" width="26" height="37" border="0" style="padding-bottom:5px"/></a> <a href="../data.html" target="_blank"><img src="../s.png" alt="" width="29" height="37" border="0" style="padding-bottom:5px"/></a><img src="../../../images/logosm.png" alt="" width="158" height="42" hspace="10" /> </td> </tr> </table> <div id="tabContent"> <div id="contentHolder"> <!-- The AJAX fetched content goes here --> </div> </div> </body> </html> Not sure if I even ask correctly. Excuse the poor PHP man for not knowing javascript. I need to add a check to this code. It picks up an image when you click on it, then puts it down when you click again. What it needs is another check WHERE (on what) have you clicked to put it down. If it's a particular DIV then OK. If not (if elsewhere) don't put it down and don't change the click counter. Code: <html> <head> <style type="text/css"> .drag { position: relative; height:56px; width:56px; background-color:#FF0000; color:White; } </style> <script type="text/javascript"> var _startX = 0; // mouse starting positions var _startY = 0; var _offsetX = 0; // current element offset var _offsetY = 0; var _dragElement; var _oldZIndex = 0; // we temporarily increase the z-index during drag var _debug; var _countClick = 0; InitDragDrop(); function InitDragDrop() { document.onclick = OnMouseClick; document.onMouseClick = OnMouseClick; } function OnMouseClick(e) { debugger; _debug = $('debug'); // if first click this is zero if (_countClick == 0) { // IE if (e == null) e = window.event; // IE uses srcElement, others use target var target = e.target != null ? e.target : e.srcElement; _debug.innerHTML = target.className == 'drag' ? 'draggable element clicked' : 'NON-draggable element clicked'; // for IE, left click == 1 // for Firefox, left click == 0 if ((e.button == 1 && window.event != null || e.button == 0) && target.className == 'drag') { // grab the mouse position _startX = e.clientX; _startY = e.clientY; // grab the clicked element's position _offsetX = ExtractNumber(target.style.left); _offsetY = ExtractNumber(target.style.top); // bring the clicked element to the front while it is being dragged _oldZIndex = target.style.zIndex; target.style.zIndex = 10000; // set _dragElement for next click _dragElement = target; // tell our code to start moving the element with the mouse document.onmousemove = OnMouseMove; // cancel out any text selections document.body.focus(); // prevent text selection in IE document.onselectstart = function() { return false; }; // prevent IE from trying to drag an image target.ondragstart = function() { return false; }; //set click count to 1 so we know next click is to release _countClick = 1; // prevent text selection (except IE) return false; } } if (_countClick == 1) { if (_dragElement != null) { _dragElement.style.zIndex = _oldZIndex; // we're done with these events until the next OnMouseDown document.onmousemove = null; document.onselectstart = null; _dragElement.ondragstart = null; // this is how we know we're not dragging _dragElement = null; _debug.innerHTML = 'mouse up'; } //set click count back to 0 so next we know it's first click again _countClick = 0; } } function OnMouseMove(e) { if (e == null) var e = window.event; // this is the actual "drag code" _dragElement.style.left = (_offsetX + e.clientX - _startX) + 'px'; _dragElement.style.top = (_offsetY + e.clientY - _startY) + 'px'; _debug.innerHTML = '(' + _dragElement.style.left + ', ' + _dragElement.style.top + ')'; } function ExtractNumber(value) { var n = parseInt(value); return n == null || isNaN(n) ? 0 : n; } // this is simply a shortcut for the eyes and fingers function $(id) { return document.getElementById(id); } function OnMouseUp(e) { } </script> </head> <body> <div id="thediv" class="drag" style='background: url(shield.gif) no-repeat center top;'></div> <pre id="debug"> </pre> <div id="slot1" class="dropon" style='position: absolute; height:28px; width:28px; top: 200px; left: 200px; background-color:#FF0000; color:White;'></div> <div id="slot2" class="dropon" style='position: absolute; height:28px; width:28px; top: 200px; left: 230px; background-color:#FF0000; color:White;'></div> </body> </html> I have an array of all links on a page (see var wa_links = document.links; below). How do I determine if the target of a link is set to "_blank"? I need to do this because currently with my code below, when a link has target="_blank" it ends up adding the Google Analytics code to the parent window and also opening a new window (so basically the new page opens in both the parent and target window instead of just the target window as expected). Code: /*Regex list of on-site domains, pipe and backslash delimited. */ var wa_onsiteDomains = /mydomain\.com|my2nddomain\.com|my3rddomain\.com|javascript/i; //Display-friendly domain and path name var wa_displayDomain = location.hostname.replace("www.","").toLowerCase(); var wa_displayPathname = location.pathname.toLowerCase(); /*Used to unobtrusivly add events to objects*/ function unobtrusiveAddEvent (element,event,fn) { var old = (element[event]) ? element[event] : function () {}; element[event] = function () {fn(); old();}; } function wa_crossDomainLink(i) { return function () { var thisLink = decodeURI(wa_links[i]); if (typeof(_gaq) == "object") _gaq.push(['_link', thisLink]); return false; }; } var wa_links = document.links; if ( wa_links ){ for(var i=0; i<wa_links.length; i++) { if( wa_links[i].href.match(wa_onsiteDomains) && !wa_links[i].href.match(location.hostname)){ unobtrusiveAddEvent( wa_links[i], 'onclick' , wa_crossDomainLink(i)); } } } With jquery I could just do something like... Code: if (jQuery(link).attr('target') == "_blank") ...but how do I do this in plain old JavaScript? Thanks! Hello, I am having some trouble with this Javascript slide show. At the moment when you click on the thumbnails they link to a larger image in a seperate browser page. I would really like to customize it so that the images open up in a smaller window on the same page. I'm sure this is something really simple but as of yet haven't been able to solve this little problem. I'm quite new to webdesign and would really appreciate some help. Thanks Hazel <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <title>Exclusive Ionian</title> <script type="text/javascript"> <!-- var timeout = 500; var closetimer = 0; var ddmenuitem = 0; // open hidden layer function mopen(id) { // cancel close timer mcancelclosetime(); // close old layer if(ddmenuitem) ddmenuitem.style.visibility = 'hidden'; // get new layer and show it ddmenuitem = document.getElementById(id); ddmenuitem.style.visibility = 'visible'; } // close showed layer function mclose() { if(ddmenuitem) ddmenuitem.style.visibility = 'hidden'; } // go close timer function mclosetime() { closetimer = window.setTimeout(mclose, timeout); } // cancel close timer function mcancelclosetime() { if(closetimer) { window.clearTimeout(closetimer); closetimer = null; } } // close layer when click-out document.onclick = mclose; // --> </script> <script> function changeimage(towhat,url, toImg){ if (document.images){ document.getElementById(toImg).src=towhat.src gotolink=url } } function sshow(){ window.location=gotolink } </script> <script language="JavaScript1.1"> var myimages=new Array() var gotolink="#" function preloadimages(){ for (i=0;i<preloadimages.arguments.length;i++){ myimages[i]=new Image() myimages[i].src=preloadimages.arguments[i] } } preloadimages("i/allegra/1.jpg","i/allegra/2.jpg","i/allegra/3.jpg","i/allegra/4.jpg","i/allegra/5.jpg") </script> <style type="text/css"> <!-- #sddm { margin: 0; padding: 0; z-index: 30} #sddm li { margin: 0; padding: 0; list-style: none; float: left; font: 11pt Trebuchet MS} #sddm li a { display: block; margin: 0 1px 0 0; padding: 0px 1px; width: 78px; background: #EDEFED; color: #999999; text-align: center; text-decoration: none} #sddm li a:hover { background: #EDEFED} #sddm div { position: absolute; visibility: hidden; margin: 0; padding: 0; background: #EDEFED; border: 0px solid #EDEFED} #sddm div a { position: relative; display: block; margin: 0; padding: 5px 10px; width: auto; white-space: nowrap; text-align: left; text-decoration: none; background: #EDEFED; color: #999999; font: 11pt Trebuchet MS} #sddm div a:hover { background: #F7CB96; color: #999999} --> </style> <link href="file:///E|/c/rou.css" rel="stylesheet" type="text/css" /> <style type="text/css"> <!-- --> </style> </head> <body> <br /> <table width="900" border="0" align="center" cellpadding="0" cellspacing="0" bgcolor="#EFEFED"> <tr> <td width="900" bgcolor="#EFEFED"> <div align="center"> <p><a href="javascript:sshow()"><img src="i/allegra/1.jpg" name="targetimage" width="900" height="425" hspace="0" vspace="15" border="0" id="targetimage"><br /> </a> <a href="file:///E|/i/allegra/1.jpg" onmouseover="changeimage(myimages[0],this.href, 'targetimage')"><img src="i/allegra/1s.jpg" width="180" height="85" hspace="0" vspace="0" border="0"></a><a href="file:///E|/i/allegra/2.jpg" onmouseover="changeimage(myimages[1],this.href, 'targetimage')"><img src="i/allegra/2s.jpg" width="180" height="85" hspace="0" vspace="0" border="0" /></a><a href="file:///E|/i/allegra/3.jpg" onmouseover="changeimage(myimages[2],this.href, 'targetimage')"><img src="i/allegra/3s.jpg" width="180" height="85" hspace="0" vspace="0" border="0" /></a><a href="file:///E|/i/allegra/5.jpg" onmouseover="changeimage(myimages[4],this.href, 'targetimage')"><img src="i/allegra/4s.jpg" width="180" height="85" hspace="0" vspace="0" border="0"></a><a href="file:///E|/i/allegra/4.jpg" onmouseover="changeimage(myimages[3],this.href, 'targetimage')"><img src="i/allegra/5s.jpg" width="180" height="85" hspace="0" vspace="0" border="0" /></a></p> </div></td></tr> <tr> <td valign="top" bgcolor="#EFEFED"><br /> <p align="left" class="style9"><br /> <br /> </p></td> </tr> </table> <p align="center"> </p> </body> </html> Hi, I am looking for the equivalent for the following Internet Explorer code for Firefox: Code: z=event.srcElement; z.style.pixelLeft = 500px; Must be something like: Code: function move(e) { z=e.target; z.style.left ..... maybe. This is to assign a new left position to an Element. Any hints welcome ?! Thank you for your help ! Hello; I have a situation where an image tag is nested in an anchor tag set. The anchor is assigned an id and is assigned a click/onclick event listener. The anchor id corresponds to a list of objects in an array. In practice, the image tag is receiving the event. The code does setAttribute in another elements img tag src attribute. The image tag receiving the click event, (and passing it to the anchor tag) is event.target. (or event.srcElement, in the case of I.E.) My Question: What I want to know is how to reference the event.target parent element, the anchor tag elements Id attribute. Code: sample anchor/img tag set: <a style="font-family:Arial, Helvetica, sans-serif;color:#cccccc" id="An 1" alt="An 1" href="javascript:"><img style="border:1px solid;border-color:#cccccc" src="WC_port/windows/img//an_1.jpg" width="100" height="131" /><br /><br />An 1</a> I see the double slash in the img src path attribute. It is working as is in test browser: Firefox ( so far) This is in development stages. Later, I will assign the elements a css class rule. in my code, event.target.src has a usable value (src attribute of the img tag) It does not have a usable value for event.target.id (id attribute of the anchor tag) I am doing it this way so in the absence of javascript, the anchors href attribute defaults to a non scripted value. Thank you for time and attention JK Hi to all, I am not an IT person but interested in discovering javascript programming. I have here codes for alarm clock but the thing is that I want the specified target URL to open in new window. If and only if I have a background with this programming maybe I could do it. Please guys, help me with this one. I found this code from javascriptkit (credit to them) <html> <head> <style type="text/css"> #jsalarmclock{ font-family: Tahoma; font-weight: bold; font-size: 12px; } #jsalarmclock div{ margin-bottom: 0.8em; } #jsalarmclock div.leftcolumn{ float: left; width: 150px; font-size: 13px; background-color: lightyellow; clear: left; } #jsalarmclock span{ margin-right: 5px; } </style> <script type="text/javascript"> /*********************************************** * JavaScript Alarm Clock- by JavaScript Kit (www.javascriptkit.com) * This notice must stay intact for usage * Visit JavaScript Kit at http://www.javascriptkit.com/ for this script and 100s more ***********************************************/ var jsalarm={ padfield:function(f){ return (f<10)? "0"+f : f }, showcurrenttime:function(){ var dateobj=new Date() var ct=this.padfield(dateobj.getHours())+":"+this.padfield(dateobj.getMinutes())+":"+this.padfield(dateo bj.getSeconds()) this.ctref.innerHTML=ct this.ctref.setAttribute("title", ct) if (typeof this.hourwake!="undefined"){ //if alarm is set if (this.ctref.title==(this.hourwake+":"+this.minutewake+":"+this.secondwake)){ clearInterval(jsalarm.timer) window.location=document.getElementById("musicloc").value } } }, init:function(){ var dateobj=new Date() this.ctref=document.getElementById("jsalarm_ct") this.submitref=document.getElementById("submitbutton") this.submitref.onclick=function(){ jsalarm.setalarm() this.value="Alarm Set" this.disabled=true return false } this.resetref=document.getElementById("resetbutton") this.resetref.onclick=function(){ jsalarm.submitref.disabled=false jsalarm.hourwake=undefined jsalarm.hourselect.disabled=false jsalarm.minuteselect.disabled=false jsalarm.secondselect.disabled=false return false } var selections=document.getElementsByTagName("select") this.hourselect=selections[0] this.minuteselect=selections[1] this.secondselect=selections[2] for (var i=0; i<60; i++){ if (i<24) //If still within range of hours field: 0-23 this.hourselect[i]=new Option(this.padfield(i), this.padfield(i), false, dateobj.getHours()==i) this.minuteselect[i]=new Option(this.padfield(i), this.padfield(i), false, dateobj.getMinutes()==i) this.secondselect[i]=new Option(this.padfield(i), this.padfield(i), false, dateobj.getSeconds()==i) } jsalarm.showcurrenttime() jsalarm.timer=setInterval(function(){jsalarm.showcurrenttime()}, 1000) }, setalarm:function(){ this.hourwake=this.hourselect.options[this.hourselect.selectedIndex].value this.minutewake=this.minuteselect.options[this.minuteselect.selectedIndex].value this.secondwake=this.secondselect.options[this.secondselect.selectedIndex].value this.hourselect.disabled=true this.minuteselect.disabled=true this.secondselect.disabled=true } } </script> <body> <form action="" method=""> <div id="jsalarmclock"> <div><div class="leftcolumn">Current Time:</div> <span id="jsalarm_ct" style="letter-spacing: 2px"></span></div> <div><div class="leftcolumn">Set Alarm:</div> <span><select></select> Hour</span> <span><select></select> Minutes</span> <span><select></select> Seconds</span></div> <div><div class="leftcolumn">Set Alarm Action:</div> <input type="text" id="musicloc" size="55" value="http://www.youtube.com/watch?v=v1zY_tV5kaQ" /> <span style="font: normal 11px Tahoma">*Location of page to launch</span></div> <input type="submit" value="Set Alarm!" id="submitbutton" /> <input type="reset" value="reset" id="resetbutton" /> </div> </form> <script type="text/javascript"> jsalarm.init() </script> </body> </head> </html> Help me please. Ive been searching for results for this one for 3 months. I have a popup window that has a "link" inside it, which needs to have a target=_blank but when ever clicked in IE, it stays inside the same window. I tried all of the following, none work PHP Code: <a href='http://www.myurl.net' onclick='window.close();' target='_blank'> <a href="http://www.myurl.net" target="_blank" onClick="javascript:window.close()"> <a href="http://www.myurl.net" target="_blank" onClick="javascript: setTimeout(window.close, 10);"> Thanks Sonny Hello. I have built a basic website that contains an iframe in the middle, called "iframe1". In this iframe I wish to load an external message board from proboards.com. In my code I can easily do this by making a button or hyper-link with the href="httproboards.com/myforums" and the rel="nofollow" target="iframe1" When I do this it will load inside of it the iframe jsut as I want it to. However, my the problem is when you click on the button to login its coded to target "_top" and it opens on the entire page replacing the whole website. If i run firebug (a real time HTML editor). I can easily locate and change the link code to rel="nofollow" target="iframe1". But How can I write a script in javascript in my webpage code to do this as soon as the iframe has loaded the external messageboard? I have also been trying things like javascript:void(document.iframe1.getElementsByTag("a")[5].rel="nofollow" target="iframe1") but i have had no luck so far in changing the target without the aid of firebug. Here is the code that needs to be changed. the rel="nofollow" target="_top" needs to be altered somehow to rel="nofollow" target="iframe1" as soon as the frame has finished loading the messageboards. Code: <p><font size="2"> Welcome Guest. Please <a href="/index.cgi?action=login" rel="nofollow" target="_top">Login</a> or <a href="/index.cgi?action=register" rel="nofollow" target="_top">Register</a>.<br/>Nov 19, 2010, 7:23pm </font><br /></p> Heres a screenshot that may help, as you can see I have easily changed the target of the link to="iframe1" using firebug, but I need to hardcode a script in my website that does this automatically after the iframe has loaded the forums page. http://img191.imageshack.us/img191/7264/26796014.jpg Thanks to for any help. I am trying to redevelop firefox addon, to give it more funcionality. I found JS file where all the functions are and started to edit it. What I want to achieve is to get target of an anchor under mouse pointer (when mouse pointer is over anchor, I right click and call addon from context menu). For example when I have anchor which HTML code is: Code: <a href="somewehere.com/place">place</a> when I right click on this code and call my addon I would like to alert its href (somewehere.com/place) I wrote a function: Code: function ff() { var current_target=this.href; alert(current_target); } but it gives me udefined on alert Any hints to achieve this are highly appreciated. Thanks |