473,789 Members | 2,807 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Getting code from a different domain into JavaScript...

Hey hey :)

Having a lot of problems with this. I'm helping my brother out with this art
school web page. He has a big wish to have random images from the web shown
in the background, and asked me to help him out.

My idea is this: Use the CNN Top Stories RSS feed to harvest keywords, then
use a random keyword from this harvest to search Google, get links from the
result, look through random links here and get links to images, then load
these images into the art web page's background.

My first thought was to use an XmlHttpRequest object, as I've played around
with it before and knew what it can do. Trouble is that Firefox needs some
kind of script signing to allow retrieving data from a different domain,
and I don't really understand how it works. Konqueror gives no warnings,
but fails to actually load the external content, perhaps because of the
same restriction. Add to this, IE seems to work, but pops up a warning
dialog to the user that a script is trying to access external content which
is unsafe. I wouldn't click okay if I saw this kind of dialog on a
different site, so I wouldn't expect anyone to do it on this site either.

Okay, so I looked for another way, and I read about iframes, thinking this
would be perfect, especially considering the .links and .images properties
already existing on a document object (making a custom lexer/parser pretty
much superfluous). The iframes themselves work great in Konqueror, Firefox,
and IE, loading content happily, problem is (as I've understood it) that
iframes aren't document objects but elements, and therefore own neither
a .links nor an .images property. Firefox console gives property not
defined errors on both document.getEle mentById('myIfr ame').document and
document/window.frames['myIframe'].document, anyway :(

I can really do fine without either of these properties if I could simply
find a way to get the external HTML code imported and script accessible so
that I can parse it with a state machine and extract what I need.

I've thought about a PHP solution too, but haven't looked into it thoroughly
yet, as I understand that very few servers allow reading files from other
domains into a local PHP script. Or is this wrong?

I'm anxious to receive any kind of tip, so long as it's crossplatform
compatible and not based on Java or something else (Flash etc.) that would
require the visiting browser to have an add-on installed. The site should
work on Safari, IE (Mac & PC), Konqueror, and Firefox. I only have the rest
of the day to get this working (approx. 10 hours) ;)

Thanks in advance,
Daniel :)

--
Why do cats jump out of windows? Because there's love out there!
Jul 23 '05 #1
4 1973
En/na DanielEKFA ha escrit:

I've thought about a PHP solution too, but haven't looked into it thoroughly
yet, as I understand that very few servers allow reading files from other
domains into a local PHP script. Or is this wrong?


i think that would be the best solution, and it would avoid getting into
the security limitations of the browser.

look into the filesystem functions
(http://www.php.net/manual/en/ref.filesystem.php)... functions like
file_get_conten ts() can get an url as an argument. so you can open any
external url and dump its contents into a variable for parsing.

you can also use the DOMDocument classes to parse the xml from feeds.
Jul 23 '05 #2
Carved in mystic runes upon the very living rock, the last words of
DanielEKFA of comp.lang.javas cript make plain:
I've thought about a PHP solution too, but haven't looked into it
thoroughly yet, as I understand that very few servers allow reading
files from other domains into a local PHP script. Or is this wrong?


You do not need to have allow_url_fopen set in your PHP installation in
order to retrieve remote content; you can simply perform HTTP operations.
There is a function in HoloLib that will allow you to do a GET.

ftp://ftp.holotech.net/hololib.zip

--
Alan Little
Phorm PHP Form Processor
http://www.phorm.com/
Jul 23 '05 #3
alex bazan wrote:
En/na DanielEKFA ha escrit:

I've thought about a PHP solution too, but haven't looked into it
thoroughly yet, as I understand that very few servers allow reading files
from other domains into a local PHP script. Or is this wrong?
i think that would be the best solution, and it would avoid getting into
the security limitations of the browser.


That's where I'm going now, too :) Gotten pretty sick of all that security
stuff, although I see why it's necessary ;)
look into the filesystem functions
(http://www.php.net/manual/en/ref.filesystem.php)... functions like
file_get_conten ts() can get an url as an argument. so you can open any
external url and dump its contents into a variable for parsing.

you can also use the DOMDocument classes to parse the xml from feeds.


Thanks, I was about to browse the php.net docs, to check out retrieval
methods, your tips will come in handy.

Cheers,
Daniel :)

--
Why do cats jump out of windows? Because there's love out there!
Jul 23 '05 #4
Alan Little wrote:
Carved in mystic runes upon the very living rock, the last words of
DanielEKFA of comp.lang.javas cript make plain:
I've thought about a PHP solution too, but haven't looked into it
thoroughly yet, as I understand that very few servers allow reading
files from other domains into a local PHP script. Or is this wrong?


You do not need to have allow_url_fopen set in your PHP installation in
order to retrieve remote content; you can simply perform HTTP operations.
There is a function in HoloLib that will allow you to do a GET.

ftp://ftp.holotech.net/hololib.zip


Very cool, thank you! As it appears, that library also sports a nifty HTML
parser, perfect! :D

Cheers,
Daniel :)

--
Why do cats jump out of windows? Because there's love out there!
Jul 23 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

19
8624
by: Neal | last post by:
I can have a visitor choose a subject line for an email. <div><label for="subject">Subject:</label><br /> <select class="form" id="subject" name="subject"> <option value="one">One</option> <option value="two">Two</option> <option value="three">Three</option> </select></div> I can also have them choose a destination.
2
7595
by: Cindy Lee | last post by:
Can this be done in https? If the page I'm on is at 'www.abc.com' can I: document.domain='www.def.com' i get invalid argument if i do that? Is there anyway around this?
7
10914
by: Lorenzo Vaina | last post by:
Can i get the content of an URL and put it in a variable using javascript? I want js execute different operations varying a file that is on internet. Thanks, regards.
2
2417
by: Scott M. Lyon | last post by:
I'm having some strange problems with a VB.NET application that I support. The application currently uses SystemInformation.UserName() and SystemInformation.UserDomainName() to determine who is logged in, and what network domain they are logged into. And for our environment here (logged into a domain), it seems to work just fine.
9
11189
by: aatcbbtccctc | last post by:
Hi folks I've googled for an answer to this, with no success. Can someone please jump in, and put me out of my misery! (I'm sure it's quite simple) I have an invisible IFRAME, and a visible DIV: <IFRAME id=myframe style="display:none" src="..." onload="ShowNews(this)"></IFRAME>
20
27799
by: Shawnk | last post by:
I would like to get the class INSTANCE name (not type name) of an 'object'. I can get the object (l_obj_ref.GetType()) and then get the (l_obj_typ.Name) for the class name. I there any way of getting 'l_Fred_my_ins' out of the following. .... My_cls l_Fred_my_ins = new My_cls();
32
5024
by: paul | last post by:
HI! I keep on getting this error and I have tried different things but I am not sure how to send the expiring date. The error that I am getting in Firefox 1.5 is "Error: expires.toGMTString is not a function" ---------------------------------------------------- I have this in a .js file and in the head section.
12
11156
by: mistral | last post by:
Can anybody tell me how to get source code of page in iframe? (popup window is clickable image). When I right click on this popup border to view source, i see just as follows <html> <head> <title>New offer!</title> </head> <body style="margin-left: 0%; margin-right: 0%; margin-top: 0%;
5
13210
by: Michael Howes | last post by:
I'm writing a utility to manage a machines *local* accounts in c# I am getting all the users in a specific Group just fine but when I want to get some of the information on each user from their Properties collection I can't get the properties on some users. For example, I get all the users that are part of my machines Administrators Group. I get get the properties of the built in local Administrator account and some local IT account,...
0
9666
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9511
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10200
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9986
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7529
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6769
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5422
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
2
3703
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2909
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.