pcadv Posted January 19, 2007 Share Posted January 19, 2007 Hi,I have created a fuction which accepts a string argument. I want the src to get the argument value in the form of string. I mean, like in the case below; I want "document.getElementById("frame1").src" to get the value of ("frame_a.htm") so that the src opens the page.<html><head><script type="text/javascript">function changeSource(imgsrc){document.getElementById("frame1").src=imgsrc}</script></head><body><div><ul><li><a href="java script:changeSource("frame_a.htm");">PA</a></li><li><a href="java script:changeSource("frame_b.htm");">St</a></li></ul></div><div><iframe id="frame1"></iframe></div></body></html> Link to comment Share on other sites More sharing options...
LittleSam Posted January 19, 2007 Share Posted January 19, 2007 <li><a href="java script:changeSource("frame_a.htm");">PA</a></li><li><a href="java script:changeSource("frame_b.htm");">St</a></li>Your problems are in these lines:You're passing your changeSource method a string encapsulated in double quotes, but remember that your href is in double quotes too. Encapsulate your argument in single quotes:<li><a href="java script:changeSource('frame_a.htm');">PA</a></li>You should be golden after that![sorry for multipe modified posts... wasn't aware that the forum added a space to "javascript"] Link to comment Share on other sites More sharing options...
pcadv Posted January 22, 2007 Author Share Posted January 22, 2007 Your problems are in these lines:You're passing your changeSource method a string encapsulated in double quotes, but remember that your href is in double quotes too. Encapsulate your argument in single quotes:<li><a href="java script:changeSource('frame_a.htm');">PA</a></li>You should be golden after that![sorry for multipe modified posts... wasn't aware that the forum added a space to "javascript"]Thanks LittleSam. Your help did solve out the problem and its working nicely. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now