简体   繁体   中英

Changing Values In An External Web Application Using Javascript

I'm currently trying to get my web application to take data from a table and enter it into an external web application. I was wondering if it was possible to do this with Javascript (without any external libraries eg jQuery, node, ect.). So far all I have is:

function otherWebsite(x){
    window.open('https://google.ie/','_blank');
}

So in that example I'd like to be able to get the id of the search bar and then enter the value x into it, then run the function to search that command on Google. I'm aware that you're able to add data to the url for Google searches but I'm trying to do it without that.

There is a great article on javascript.info on how to achieve cross-window communication. See this for a general overview about this topic:

javascript.info: Cross-window communication

And see also in detail:

MDN: Window.postMessage()

“The window.postMessage() method safely enables cross-origin communication between Window objects; eg, between a page and a pop-up that it spawned, or between a page and an iframe embedded within it.”

Things getting much more complicated if the domains differ because of the security policy of browsers. Note the security concerns on the MDN page about the postMessage method.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM