fixed localswitch function and added iframe case