1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

Need help with a tricky JS problem...

Discussion in 'JavaScript' started by itsme, Nov 9, 2009.

  1. #1
    Alright, here is what I need to do:

    [EDIT] What I want to do is cross-domain communication with JS, which is to the best of my knowledge, not possible unless I can configure BOTH servers to communicate with each other... in other words, this is not possible?? If anyone has a workaround, please let me know. [/EDIT]

    I have users of my website fill out forms, I then need to load data from certain fields from their forms into a 3rd party webform (ie. on another domain)

    The solution I came up with was to have a frameset, the top frame contained the user input, while the bottom frame loaded the 3rd party webform. Whenever I would click on the appropriate button/link in MY top frame (the one with the user data) it would trigger a JS function to copy that data into the appropriate field in the 3rd party form. Here is an example:

    $('#myButton').click(function(){
    var x = $('#input_1').val();
    parent.bottomFrame.document.getElementById("3rd_party_form_element_id").value = x;
    })


    I am using jQuery to detect the click, but using an onClick= doesn't change anything...

    THIS WORKS BY THE WAY, but only when I'm using it to populate form data on another page that resides on my server... but I'm having problems populating the 3rd party webform.

    Does anyone have an idea why this is? Am I not referencing the element properly??

    Big thanks and some rep to anyone who helps me solve this one! :)

    Cheers,
    Pete
     
    Last edited: Nov 9, 2009
    itsme, Nov 9, 2009 IP
  2. semantic7

    semantic7 Member

    Messages:
    92
    Likes Received:
    5
    Best Answers:
    0
    Trophy Points:
    48
    #2
    This is most likely not possible as this can potentially be a huge security risk. Imagine you login data being sent of to another site while you were trying to login to your bank because there was second form that was collecting data. I am not completely sure about this.
     
    semantic7, Nov 9, 2009 IP
    itsme likes this.
  3. dimitar christoff

    dimitar christoff Active Member

    Messages:
    882
    Likes Received:
    62
    Best Answers:
    0
    Trophy Points:
    90
    #3
    XSS is not possible due to security implications. what's to stop you from:

    - creating a phishing page frameset that embeds the HSBC online banking login form
    - mail users to login and change their pass
    - enable some js listeners / loggers or change the login form's action page to one on your domain where you can capture the details

    see my point? it would break the internet totally. alas, not even for all the rep in the world--you just can't do this with a _compliant_ / mainstream browser. although... you can do it using something like greasemonkey or jetpack, i suppose...
     
    dimitar christoff, Nov 9, 2009 IP
    itsme likes this.
  4. itsme

    itsme Well-Known Member

    Messages:
    1,232
    Likes Received:
    96
    Best Answers:
    0
    Trophy Points:
    180
    #4
    Thanks guys... not looking to do any phishing, I'm actually looking for an easy way to cut/paste form data from my database without actually having to do the copy/paste thing for thousands of fields.

    I'll have to find another solution I suppose.
     
    itsme, Nov 10, 2009 IP
  5. camjohnson95

    camjohnson95 Active Member

    Messages:
    737
    Likes Received:
    17
    Best Answers:
    0
    Trophy Points:
    60
    #5
    One possibility is to create a windows application that your users can download. This could have a web browser embedded and fille the forms out for any domain. Easy enough to do with .NET, but less convenient. Or if it's only you that needs to use it, it is probably a good option.
     
    camjohnson95, Nov 11, 2009 IP
    itsme likes this.
  6. itsme

    itsme Well-Known Member

    Messages:
    1,232
    Likes Received:
    96
    Best Answers:
    0
    Trophy Points:
    180
    #6
    This is purely an administrative task, so it's only me that needs to use it... I think I'll probably look into creating a standard desktop application to do this, or maybe a browser plugin (but probably an app).

    Thanks to everyone for their input!

    Cheers,
    Pete.
     
    itsme, Nov 11, 2009 IP
  7. camjohnson95

    camjohnson95 Active Member

    Messages:
    737
    Likes Received:
    17
    Best Answers:
    0
    Trophy Points:
    60
    #7
    if you need a hand let me know. I've made a few personal desktop apps that do similar, using vb and c# .net
     
    camjohnson95, Nov 12, 2009 IP
  8. melol2

    melol2 Active Member

    Messages:
    511
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    80
    #8
    Why not:

    a) Have the 2nd form read directly from the same SQL server (is there an SQL Server involved?)

    b) communicate via GET variables and just have the frame src adjusted to the information?

    frame1.src="blah.com/blah.php?username="+blah+"&information="+blah2;

    This normally wouldn't be too secure unless implemented correctly. But since you will be the only one using it, I don't see there being a problem.

    ALTERNATELY: You use PHP to connect to sockets and send the information itself.

    There are many eccentric ways to accomplish this task. Whether or not theyd be efficient enough is up to you.
     
    melol2, Nov 12, 2009 IP
  9. camjohnson95

    camjohnson95 Active Member

    Messages:
    737
    Likes Received:
    17
    Best Answers:
    0
    Trophy Points:
    60
    #9
    That could work depending on the situation. If other fields need to be filled out manually then it could make it more difficult. and if some of the pages use GET and some use POST amd some are .NET with a viewstate it can complicate things. whereas if you use software to fill out the forms and submit them (simulating a regular user) it could be easier. it depends on the website(s) that the data is being submitted to. I have tried POSTing data to ASP.net websites and have yet to succeed.
     
    camjohnson95, Nov 12, 2009 IP
  10. dimitar christoff

    dimitar christoff Active Member

    Messages:
    882
    Likes Received:
    62
    Best Answers:
    0
    Trophy Points:
    90
    #10
    seriously, building custom apps? very cool but why bother when greasemonkey - https://addons.mozilla.org/en-US/firefox/addon/748 or jetpack - https://jetpack.mozillalabs.com/ can allow you to customise whatever you want on any webpage through standard javascript.

    greasemonkey is soooo coool. i use it to "hack" id software's quakelive built in gamebrowser and replace it with my own version that's got a much nicer UI. i mean, when you think about - there are so many things you'd want to do to existing sites to improve them or integrate something into them.

    here's my favourite greasemonkey script of all time - improving and fixing google SERPS :) http://userscripts.org/scripts/show/9310
     
    dimitar christoff, Nov 12, 2009 IP
  11. shubhamjain1

    shubhamjain1 Peon

    Messages:
    75
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #11
    Well make a proxy on your domain. Create ajax request to it and make Proxy browse to the 3rd domain you want.
     
    shubhamjain1, Nov 14, 2009 IP