SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Member
    Join Date
    Jun 2008
    Posts
    2
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Question xml http request or another solution

    Hi!
    I have a serious issue.
    i want to refresh the banners on our site every minute.
    so i created a timer, that will call the function for the banner.
    The function is a third party function that actually uses: document.write() methods.
    The problem is that when i call the function it prints it on the screen.
    so i tried to print it to div like this:
    div.innerHTML = "<script>theFunction();</script>"
    but again it prints to the screen.
    I thought to use XMLHTTPRequest.open method = so i will get the request as string and write it using the eval() function, but since it's a different domain, i get a permission denied message. I don't want to use proxy from security reasons.
    is there another way to solve it?

  2. #2
    SitePoint Wizard Pepejeria's Avatar
    Join Date
    Jan 2005
    Location
    Too far up north
    Posts
    1,566
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    A way to do it would be to have the banner in an iframe. The iframe content could then be rewritten with document.write without affecting the outer document (your page).

  3. #3
    SitePoint Member
    Join Date
    Jun 2008
    Posts
    2
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    can the iframe contain javascript? how can i call a javascript function in iframe?

  4. #4
    SitePoint Wizard Pepejeria's Avatar
    Join Date
    Jan 2005
    Location
    Too far up north
    Posts
    1,566
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    An iframe is just a floating frame with an HTML document like any other page. Meaning that it can contain whatever a normal page can contain.

    You can access any JavaScript function in the iframe with this syntax
    Code JavaScript:
    window.frames.iframeName.functionName();


Tags for this Thread

Bookmarks

Posting Permissions

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