Jump to content

javascript: 'dynamic iframe and location' -- possible ?


BluePhoenixNC

Recommended Posts

My appologies, I am not a JS junkie and just starting out with the whole thing so please be patient with me.
I was wondering if it is possible to create an iframe in Javascript dynamically. have it load a certain page based on a variable and, assign the iframe a CSS class (which is to determine the height and width of that frame as opposed to have to go through the js code and change those attributes) and place the whole thing into a specified div container.
here is what I had so far:
[code]function createFrame(url) {
  var placeDIV = document.getElementById("placeme");
  var xIFrameElement = document.createElement("iframe");
  xIFrameElement.frameBorder = 0;
  xIFrameElement.name = "someFrame";
  xIFrameElement.id = "someFrame";
  xIFrameElement.class = "frameclass"; //not sure about that one if this is valid
  xIFrameElement.location = url; //not sure either
  placeDiv.appendChild = (xIFrameElement);
}
[/code]
But it just does not 'activate' and I am not sure how to proceed.

Any help is greatly appreciated.

Thanks
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.