Jump to content

re-setting target attrib and Compatibility View?


ginerjm

Recommended Posts

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?

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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 by nogray
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.