SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Member
    Join Date
    Feb 2009
    Posts
    13
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Cross-Domain Functionality with Browser Add-ons?

    Is it possible allow a user select content from a web page and send it to a different server using a Browser plug-in or add-on?

    My background is LAMP, C, Javascript, AJAX. I'm pretty knowledgeable about all of these, but I'm rather clueless when it comes to browser add-ons or plug-ins, so forgive me if some of my questions sound somewhat ignorant.

    What I'm trying to do:

    I'd like to develop a tool that will allow a person reading a web page to be able to select a word on that page, and through a mouse right click or by hitting a button in a browser add-on, send that web to my server, and have my server send back a definition, or translation, or other statistics about that word, displayed in the browser add-on toolbar, or possibly as a pop-up (I'm leaning away from the latter as I want my tool to interfere as little as possible with the target web page being viewed).

    In other words:

    www.xyz.com -> [web page content] -> client
    client -> [selected word] -> www.myserver.com
    www.myserver.com -> [info about word] -> client
    xyz.com is the site serving the content (eg, www.cnn.com, www.tmz.com, etc)
    myserver.com is my server, with dictionary or other stats stored in a database.

    Obviously, what I want to do here requires cross-site (domain) access. I don't want a hack, and I don't want to do it in a way that is considered "illegitimate", as I may want to pursue this as a for-profit eduction product.

    Perhaps it's not technologically possible, but if it is I think it would be through a browser plug-in, which I know little about and thus this post...

    Here are two options I've considered:

    (1) Browser add-on (specfically, firefox)
    For example, a tool like: Web Developer (https://addons.mozilla.org/en-US/firefox/addon/60/)

    My understanding is that these are written in Javascript, but the user has to specifically install them into their browser (which is fine for my purpose).

    Q: Would this be able to implement the functionality I describe above (that is, let the user select words from one domain and send them to my server)?

    Possible Downside: This would have to be ported to IE, and every other browser, and may not be an easy port.

    (2) Internet Explorer "plug-in" using Win32 (that is, a .exe that gets downloaded and run by user on client, which installs the add-on/plug-in to explorer).

    example: www.meep.com

    Q: Would this be able to implement the functionality I describe above (that is, let the user select words from one domain and send them to my server)?

    Any other thoughts or ideas would be appreciated.
    Thanks,

    Helo

  2. #2
    SitePoint Member
    Join Date
    Feb 2009
    Posts
    13
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    bump...any feedback on this?

    I'm beginning to think a Windows .exe that the user has to download and install is the only way. That makes supporting Mac a bit of an issue though.

    Peter

  3. #3
    Programming Since 1978 silver trophybronze trophy felgall's Avatar
    Join Date
    Sep 2005
    Location
    Sydney, NSW, Australia
    Posts
    16,600
    Mentioned
    24 Post(s)
    Tagged
    1 Thread(s)
    You don't have your path specifiied quite right.

    Instead of:

    www.xyz.com -> [web page content] -> client
    client -> [selected word] -> www.myserver.com
    www.myserver.com -> [info about word] -> client

    you need to instead use:

    www.xyz.com -> [web page content] -> client
    client -> [selected word] -ajax-> www.xyz.com -> www.myserver.com
    www.myserver.com -> www.xyz.com -ajax->[info about word] -> client

    The current page uses ajax to pass the request to a script on the current server without reloading the page. That script then accesses the remote server to retrieve the desired info and pass it back to the ajax script.

    That is the only way to do it as there are all sorts of security issues with allowing direct access to a different server from within the browser - which is why the browser is specifically designed to disallow it.
    Stephen J Chapman

    javascriptexample.net, Book Reviews, follow me on Twitter
    HTML Help, CSS Help, JavaScript Help, PHP/mySQL Help, blog
    <input name="html5" type="text" required pattern="^$">


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
  •