garethhall Posted March 4, 2010 Share Posted March 4, 2010 Hello I want to create an iframe and then target it. The frame creation part is working but I can't seem to target it Please help function getFile(fileID,compID){ var theFrame = document.createElement('iframe'); theFrame.setAttribute('name','theDload'+fileID); theFrame.setAttribute('width','100'); theFrame.setAttribute('height','100'); theFrame.setAttribute('id','theDload'+fileID); document.getElementById('theDFrame').appendChild(theFrame); theDload[fileID].location = './main.php?fileID='+fileID+'&compID='+compID; // problem on this line???? } Quote Link to comment Share on other sites More sharing options...
roopurt18 Posted March 4, 2010 Share Posted March 4, 2010 Do you receive a JavaScript error? Does it attempt to load anything? What exactly is the problem? Quote Link to comment Share on other sites More sharing options...
garethhall Posted March 4, 2010 Author Share Posted March 4, 2010 The error is: Result of expression 'theDload[fileID]' [undefined] in not an object Quote Link to comment Share on other sites More sharing options...
roopurt18 Posted March 4, 2010 Share Posted March 4, 2010 You're trying to set the location of the iframe, right? Why aren't you using the variable theFrame? Quote Link to comment Share on other sites More sharing options...
garethhall Posted March 4, 2010 Author Share Posted March 4, 2010 Well theFrame is the created element right? and not the name element. I updated the code and now get this error 'INVALID_STATE_ERR: DOM Exception 11' theFrame.location = './main.php?fileID='+fileID+'&compID='+compID; Quote Link to comment Share on other sites More sharing options...
Dennis1986 Posted March 4, 2010 Share Posted March 4, 2010 function getFile(fileID,compID){ var theFrame = document.createElement('iframe'); theFrame.setAttribute('name','theDload'+fileID); theFrame.setAttribute('width','100'); theFrame.setAttribute('height','100'); theFrame.setAttribute('id','theDload'+fileID); document.getElementById('theDFrame').appendChild(theFrame); theFrame.setAttribute('src', './main.php?fileID='+fileID+'&compID='+compID); } Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.