marlai Posted May 31, 2008 Share Posted May 31, 2008 Dear All,Below are 3 web pages, main.htm contain 3 frames, it load hh.html on header frame and empty.html on leftFrame and rightFrame.All java script:alert(date) work OK, but got error in the 1st link {alert(d) target="rightFrame"} when Google link is clicked, please help. ============ main.htm<HTML><!-- When open this html in IE, all java script:alert(date) in hh.html is OK, once Google clicked, <a href="java script:alert(date)" target="rightFrame"> got error, please help to solve it, I know remove "target=rightFrame" can solve it, but I need this to load other web page on rightFrame. --> <HEAD> </HEAD> <FRAMESET ROWS="94,*" framespacing=1> <FRAME src="HH.html" name="header" noresize scrolling="NO"> <FRAMESET cols="200,*" onResize="if (navigator.family == 'nn4') window.location.reload()"> <FRAME src="empty.html" name="leftFrame"> <FRAME src="empty.html" name="rightFrame"> </FRAMESET> </FRAMESET></HTML> ====== hh.html When open this html in IE, all java script:alert(date) in hh.html is OK, once Google clicked, "java script:alert(date)" target="rightFrame" got error, please help to solve it, <BR>I know remove "target=rightFrame" can solve it, but I need this to load other web page on rightFrame.<BR> <a href="java script:var d = new Date(); alert(d)" target="rightFrame"> <b> "java script:alert(date)" target="rightFrame" </b> </a> <a href="java script:var d = new Date(); alert(d)" name="leftFrame"> <b> "java script:alert(date)" name="leftFrame" </b> </a> <a href="java script:var d = new Date(); alert(d)" > <b> "java script:alert(date)" </b> </a> <a href="http://www.google.com.hk/" target=rightFrame> <b> Google target=rightFrame </b> </a> ===== empty.html empty.html (no content, file size = 0) Link to comment Share on other sites More sharing options...
Synook Posted May 31, 2008 Share Posted May 31, 2008 I don't understand what you want to achieve with the target attribute, and your meaning of "Google clicked". The alert will be pop up as a seperate window, and no page will be loaded :S Link to comment Share on other sites More sharing options...
Ingolme Posted May 31, 2008 Share Posted May 31, 2008 Do it this way:<a href="new URL" onclick="var d = new Date(); alert(d)" target="rightFrame"> Link to comment Share on other sites More sharing options...
Synook Posted May 31, 2008 Share Posted May 31, 2008 I see Link to comment Share on other sites More sharing options...
Jesdisciple Posted May 31, 2008 Share Posted May 31, 2008 First, try putting quotes around Google's TARGET value.If that doesn't work, I need some clarification... Is it before or after the Google link is clicked that you get an error when clicking the troublesome link?BTW, why are you targeting JS links to other windows? And what are you using name="leftFrame" for in the second link?EDIT: Woops, I'm a little late... Link to comment Share on other sites More sharing options...
marlai Posted June 1, 2008 Author Share Posted June 1, 2008 Dear All,I have put my question in below web page, please click below and help me.Please click here for my demo pagehttp://www.hkstar.com/~marlai/w3school/askForHelp.htmlThanks. Link to comment Share on other sites More sharing options...
Jesdisciple Posted June 1, 2008 Share Posted June 1, 2008 I think that's a security feature of the browser. If you can execute JavaScript on a page in another site (like Google), you can spy on the user's interaction with that site.Can you accomplish your goal without executing JavaScript in Google? EDIT: I think you can change the URL of rightFrame, can't you? <a href="http://hk.yahoo.com/" target="rightFrame">Yahoo! target=rightFrame</a> Link to comment Share on other sites More sharing options...
marlai Posted June 5, 2008 Author Share Posted June 5, 2008 I think that's a security feature of the browser. If you can execute JavaScript on a page in another site (like Google), you can spy on the user's interaction with that site.Can you accomplish your goal without executing JavaScript in Google? EDIT: I think you can change the URL of rightFrame, can't you?<a href="http://hk.yahoo.com/" target="rightFrame">Yahoo! target=rightFrame</a> As the left frame will be a tree list, I need JS to expand the tree to get more selection for user, and also perform other JS function in main.htm. Link to comment Share on other sites More sharing options...
Jesdisciple Posted June 5, 2008 Share Posted June 5, 2008 You can use JS to change the URL of the middle frame, but while it's at a different site you cannot (generally) execute JS within it. However, once you change the URL back to your site, the browser will allow you to use JS within it again.Just what are you wanting to do within that frame? EDIT: BTW, Ingolme gave a good solution for executing JS and changing the URL with the same link. Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.