ginerjm Posted March 24, 2013 Share Posted March 24, 2013 Seem to be having a problem with my php/js application since I upgraded my laptop with IE9. My pages were written to use a JS function to modify the target of my form before submission for certain actions on that form. Sometimes I want the php script to return its output back to the current page, but for other actions (depending on the button clicked) I want to send the php script output to a new window. Well, it doesn't work any more and I've found that it will work IF I click on Tools,Compatibility View in my browser. Not totally understanding what the compatibility view means and how it would impact my appl and not wanting my users to have to worry about this, is there something I can do in my JS to enforce the new target? Quote Link to comment https://forums.phpfreaks.com/topic/276098-re-setting-target-attrib-and-compatibility-view/ Share on other sites More sharing options...
haku Posted March 25, 2013 Share Posted March 25, 2013 It sounds like your javascript may not well formed. Run it through a validator, it will make it more compatible: http://www.jslint.com/ Quote Link to comment https://forums.phpfreaks.com/topic/276098-re-setting-target-attrib-and-compatibility-view/#findComment-1420819 Share on other sites More sharing options...
ginerjm Posted March 25, 2013 Author Share Posted March 25, 2013 Never use jslint before - what a pia! Except for "spacing" errors and jslint's preferred location of curly braces, my script seems ok. Here it is - something that worked before but now doesn't. I have added some 'alert' statements to help ensure it is working (even tho it doesn't). OH - and that's another thing jslint didn't like - it wanted me to declare 'alert'. Didn't know one had to do that var rtnbtn_used = false; function changeAction(btn) { alert("in x changeaction with " + btn); if (btn === 'btn') { rtnbtn_used = true; return true; } else { if (!rtnbtn_used) { alert("newwin"); document.getElementById("thisform").target = "newwin"; rtnbtn_used = false; return true; } else { document.getElementById("thisform").target = "_self"; return true; } } } Basically - I call this function with an onclick from my 'return' button in my screen as well as from my onsubmit event of my form. If the return has been hit and will do a submit, the onclick sets a switch which when my form calls this function will trigger a normal return to the same window. But if a different button has been clicked to trigger submission, the lack of the "rtnbtn" switch being 'true' will cause the target be set to open a new window. I use this on my windows that are going to build a pdf for display and I don't want to replace the current window since the user can then simply close the pdf window and generate another pdf. If I just used the single window, then a return (back) from the pdf displayed would send them back a screen too far in my appl. making it tedious to use the pdf generator repeatedly. Quote Link to comment https://forums.phpfreaks.com/topic/276098-re-setting-target-attrib-and-compatibility-view/#findComment-1420922 Share on other sites More sharing options...
nogray Posted March 25, 2013 Share Posted March 25, 2013 (edited) Some browsers now treat an onclick return value as the submit return value in submit buttons. For example, if your onclick returned false (or cancelled the event), the form won't be submitted. You might want to change your logic and make the click event set some variables for the submit method to check and do what you need. Edited March 25, 2013 by nogray Quote Link to comment https://forums.phpfreaks.com/topic/276098-re-setting-target-attrib-and-compatibility-view/#findComment-1420970 Share on other sites More sharing options...
haku Posted March 26, 2013 Share Posted March 26, 2013 Please use code tags around your code. You can do this with the <> button in the editor. Quote Link to comment https://forums.phpfreaks.com/topic/276098-re-setting-target-attrib-and-compatibility-view/#findComment-1421055 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.