hi, I need to be able to change the src of an iframe based on what computer a user has (mac/PC). I have got the script to do the detection part but not sure how to get it to change the src in the iframe. any help much appriecated chris
well, if you can detect the OS and have which url should iframe be loaded with on detection of a particular OS, then simply add following line in javascript where you want to load the iframe.. window.frames[FRAME_NAME].src = SRC_URL; where FRAME_NAME = name of the frame you wish to load with url. SRC_URL = the url you wish to load into frame. Hope this helps, if confused, post your detection code and urls for different OS. We will help you write a js code for the same.
if using jquery then user is like if(mac){ $('#iframeid').attr('src','source1') }else{ $('#iframeid').attr('src','source2') }
Hi Guys, I am really struggling with this so any help would be good. I have never used javascript before. The URL for the iframe if OS is mac: www.cerysrhysjones.co.uk/mac The URL for the iframe if OS is win: www.cerysrhysjones.co.uk/pc The script i have so far is this: <script type="text/javascript"> if((navigator.platform.match("Mac"))) { window.frames[medialinks].src="www.cerysrhysjones.co.uk/mac" } else { window.frames[medialinks].src="www.cerysrhysjones.co.uk/pc" } </script> To be honest i am not sure that this works. Let me know what you think. Cheers CHRIS
cheers for all your help i managed to do it in the end after some tweaking. only problem i now have is that the iframe position will not move. Explanation: the website width is only 750px therefore you see a certain amount of the browser background - that is fine. I have set the position of the iframe but if i reduce the size of the window the iframe does not move but the rest of the site does. any help appreciated - i am sure it is something really silly that i am doing/not doing. CHRIS