gibney.org
:
Technology
:
Javascript
:
Bookmarklets
:
FormTarget
(Entry Nr. 87, by user 1 |
edit
)
// <textarea class=code_area> /* Bookmarklet Skript by Gibney-Enterprises This one enables you to submit a form to a new window if you shift-click on a submit button. */ {CATEGORY_DESCRIPTION_59} ge_require_once('http://javascript.gibney.org/message_box.js'); var isDOM=document.getElementById&&!document.all; var ge_FormTarget_lastTarget=''; var ge_FormTarget_lastForm=''; function changeTarget(e) { if (ge_FormTarget_lastForm) { ge_FormTarget_lastForm.target=ge_FormTarget_lastTarget; } if (!e) e = window.event; if (!((e.button && e.button == 1) || (e.which && e.which == 1))) return; // no left click if (!((e.shiftKey) || (e.modifiers && e.modifiers==4))) return; // no shift pressed var tempObj = isDOM ? e.target : e.srcElement; if (!(tempObj.tagName=='INPUT' && tempObj.type=='submit')) return; // not clicked on an input submit while(tempObj.parentNode && tempObj.tagName!='FORM') { tempObj=tempObj.parentNode; } if (tempObj.tagName!='FORM') return; // no form found ge_FormTarget_lastForm =tempObj; ge_FormTarget_lastTarget=tempObj.target; tempObj.target='_blank'; } // ---------------------------------------------------------------------------------- // Main // ---------------------------------------------------------------------------------- function main() { var messageBoxId=ge_messageBox('http://en.gibney.org/formtarget_info/','<b style="color:008000">FormTarget</b> is active.<br>Shift+Click on a submit Button to submit the form to a new window.',true); if (document.layers) document.captureEvents(Event.MOUSEDOWN); document.onmousedown=function(e) { changeTarget(e); // removeDiv(messageBoxId); hideMessageBoxOnClick(e); } } startMain(); // </textarea>
Create a new entry at this position