Home › Forums › JavaScript › ability to use cross domain css on another site… possible with JS?
- This topic is empty.
-
AuthorPosts
-
October 20, 2013 at 4:27 pm #153566
timaging
Participanthi,
ok, so check out this page
http://www.retrosheet.org/boxesetc/B/FR_BOS.htm
I want to have an iFrame on a local site, but create styles for this site that’s hosted elsewhere. Is there a way to do that? I don’t have access to that site, but want to display the information and have it look nicer.
I asked in the CSS forums and they said possibly could be done with js?
thanks!
DaveOctober 20, 2013 at 4:49 pm #153570Senff
ParticipantNope, impossible.
October 21, 2013 at 10:48 am #153611timaging
Participantso, apparently it is possible. I have a friend that’s done it but he hasn’t done it in a while. This is what he recalls so far:
_collect all the content into a javascript array.
It may be that you can use a dom object for that – something that can hold the whole document as an html object.
Then you can iterate over the object element by element and add a style attribute. Finally, add a link to your css sheet in the header of your dom object.
Then write the object out to the page.
In effect, you’ve scraped the other page, and are writing your own version.
_
I just don’t know how to write that. I’ll see if he can help me and if so we can show you how to do it.October 21, 2013 at 11:34 am #153617timaging
ParticipantHi Mottie,
My understanding is that as long as we credit the source then we are allowed. That is stated o the site. I’m just trying to make those dang baseball stats look nicer.
It actually looks like you can create a widget, but I still can’t seem to figure out how to create my own style:
there appears to be css=1, so Maybe turning that to css=0 then I can apply, but I don’t know how that would even connect?
October 21, 2013 at 11:36 am #153618timaging
Participantok, and I’m not sure if you are even seeing my code, but there is something seriously wonky with adding certain things to this page. I don’t know what that problem is.
October 21, 2013 at 4:17 pm #153640__
ParticipantMy understanding is that as long as we credit the source then we are allowed.
That is completely untrue. “Things on the internet” are not automatically public domain, nor does it imply consent-if-attribution or any other licensing model. You need to check the Terms of Service on the site you wish to use content from. If those Terms are unclear (or nonexistent), you need to contact the site owner for permission.
That is stated o [sic] the site.
I don’t see that… I do see this, on their FAQ page:
All data contained at this site is copyright © 1996-2007 by Retrosheet. All Rights Reserved.
?
I’m not sure if you are even seeing my code
I don’t see any code in your posts above, no.
To explain @Senff’s comment, the reason you “can’t do it” is the same-origin policy, which all major browsers enforce nowadays. If your iframe’d content is on the same domain as your site (it’s not, in this case), or if you can get the site owner to allow Cross-Origin Resource Sharing, then you can do what you’re describing – otherwise, it will be hacky/fragile at best (and illegal at worst).
-
AuthorPosts
- The forum ‘JavaScript’ is closed to new topics and replies.