Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 5 of 5
  1. #1
    Regular Coder Kevin_M_Schafer's Avatar
    Join Date
    Apr 2011
    Location
    Fairfax, Minnesota, U.S.A.
    Posts
    482
    Thanks
    97
    Thanked 17 Times in 17 Posts

    Using Java Script to remove an iframe border

    I found this thread here on CodingForums regarding the use of Java Script to implement an iframe on a page, while at the same time remove its border: http://www.codingforums.com/showthread.php?t=140363

    Code:
    var iframe = document.createElement("iframe");
    iframe.id = "flashlatest1";
    iframe.width = "419";
    iframe.height = "240";
    iframe.src = "pageURL";
    iframe.setAttribute("frameBorder","0");
    // i did try the following line instead which didn't work...
    //iframe.frameBorder = "0";
    iframe.scrolling = "no";							
    appendChild(iframe);

    I'm not very familiar with java script. For this to work, do I need to create an element for each: id, width, height, src, etc.?

    Also, would this script simply be placed between tags like these on my page?
    Code:
    <script type="text/javascript"> and </script>
    A bit of direction would be appreciated.


    ...
    My keyboard is an IBM from 1993 and I like it that way. | Who is Dan Well? Everyone always says I know Dan Well.Building a web page is like building a birdhouse. Put it up there and watch 'em come. | Maintaining the aspect ratio of an image is more important than having a cold orange pop.

  • #2
    Senior Coder
    Join Date
    Aug 2006
    Posts
    1,405
    Thanks
    11
    Thanked 298 Times in 297 Posts
    Let me ask a question which may have religious implications...

    Why are you implementing an iframe via JS, rather than <iframe> in html with its associated attributes (like "frameborder")

    Dave

  • #3
    The fat guy next door VIPStephan's Avatar
    Join Date
    Jan 2006
    Location
    Halle (Saale), Germany
    Posts
    8,881
    Thanks
    6
    Thanked 1,035 Times in 1,008 Posts
    Probably because of validation issues?

  • #4
    Senior Coder
    Join Date
    Aug 2006
    Posts
    1,405
    Thanks
    11
    Thanked 298 Times in 297 Posts
    I was wondering that, but surely (actually I'm asking this as a question) if an html iframe has validation issues, doing the same thing by stuffing an iframe in via the DOM is equivalent to sticking one's head in the sand?

    Dave

  • #5
    Regular Coder Kevin_M_Schafer's Avatar
    Join Date
    Apr 2011
    Location
    Fairfax, Minnesota, U.S.A.
    Posts
    482
    Thanks
    97
    Thanked 17 Times in 17 Posts
    Hi Dave,

    This really bites. Why does IE have to be like this? I've resorted to using border="0" in the html iframe code.

    I know what you mean about sticking one's head in the sand, but I just thought if it could be done with js, why not give it a try.
    My keyboard is an IBM from 1993 and I like it that way. | Who is Dan Well? Everyone always says I know Dan Well.Building a web page is like building a birdhouse. Put it up there and watch 'em come. | Maintaining the aspect ratio of an image is more important than having a cold orange pop.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •