You can use the XMLHTTP component or IFRAME to obtain data from the same domain. This is simple because there is no cross-origin access permission problem.
However, to access data in different domains, XMLHTTP does not have the permission to obtain data due to browser security settings, and IFRAME does not have the permission to pass the obtained data to the parent window, there seems to be no other solution.
Epiphany ......
Scripts that reference different domains on the webpage do not prompt insufficient permissions. By the way, it is true!
The solution is found. Now let's test it briefly:
First, create a page (test.html) on the 51js.comserver ).
<Html> <pead> <title> Over-Domain Data Fetching Test Page </title> </pead> <body> <button onclick = "loadScript ('HTTP: // aboutplayer.com/alert.js') "> Test Alert </button> <button onclick =" loadScript ('HTTP: // aboutplayer.com/info.js') "> Get My Info </button> My Name: <input id = "myname" type = "text" value = ""> My Blog: <input id = "myblog" type = "text" value = ""> </body> </ptml>
[Ctrl + A select all Note: If you need to introduce external Js, You need to refresh it to execute]
Two key points are explained:
1. lastScript is used to store the ID of the last created script node. When you create another script node next time, you need to delete the last created node to avoid loading more scripts and occupying too much memory.
2. A value d is added to the url to prevent the browser from caching script data. In this example, the value d is not added. However, if the script is dynamically generated by the server, it is best to add it.
Then create two java script scripts for testing.
Alert. js:
Alert ('You can see me! ');
Info. js:
G ('myname'). value = 'music audience ';
G ('myblog'). value = 'www .aboutplayer.com ';
After all, music has put the followers in the aboutplayer.comserver, and test.html are not in the same domain.
Open the test.html file with a browser.
Click "Test Alert". The displayed dialog box is displayed !.
Click "Get My Info". The information on this site is displayed in the text box.
Then, if you put the Lrc lyrics data into the Js script file (instead of directly changing the file extension), you can obtain the Lrc lyrics data across domains.