SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Member
    Join Date
    Jul 2007
    Posts
    19
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Cross domain problem

    well im trying to count the script request send in cross domain scenario
    as almost all the browsers have it restricted
    i need a way to get the no of request for my script when i traverse through different pages which all request this script
    i need to keep a count for the no of requests for the script and if gets more than 5 then the script should display that u cannot request for this script more than 5 times
    it seems to work when i call the script more than 5 times from a single webpage
    but it fails when i traverse through 1 page to another which all request it
    like in main.html page i have <iframe src="next.html"> and in the next.html i have <script src="sample.js"> when i click from main.html to next.html the script count should increase from 1 to 2 and if i keep on traversing through diffrent pages who all request this script, the count should increase

    im using this code to check the no of count

    Code JavaScript:
    if((n=calculate(document.getElementsByTagName('script')))<6  )

    if the no of counts r less than 6 then the script should do what its supposed to do otherwise it should reply as script cant be accesed more tha 5 times

    the function calculate counts the no of request for that script
    i use a countScript to keep the no of count and i use

    Code JavaScript:
    if(top.countScript==null){top.countScript=1;}else{top.countScript=top.countScript+1;}

    this works fine when all requests originate from a single html page but if i traverse through multiple webpages which all request this script
    the top.countScript always returns as null

    i need the top.countScript to keep the no of record of requests earlier made which it doesnt

    can u help me with some code that can keep the no of counts for the scripts when it is a cross domain issue
    thanks in advance

  2. #2
    SitePoint Member
    Join Date
    Jul 2007
    Posts
    19
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    it should not only pass information only through iframe.
    it should send the no of counts for that requested script everytime
    suppose we have the script called from two web pages page1.html and page2.html
    page1.html has <script src="example.js"> and so does page2.html
    and page 1 has a link to page 2 so when i click on that link the script request should increment by 1
    but the counter im using always has null in the no of counts
    i need a counter which can keep the count made till now and pass it to the next script request in cross domain


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
  •