I'm trying to load an external page and run auto login script. This is what I got so far, but it's not working =( Any help be appreciated!
<html>
<head>
<script type="text/javascript">
javascript:(function(){
window.open ("https://external page address","_self");
document.getElementById("username").value="my username";
document.getElementById("password").value="my password";
document.getElementById("loginbutton").click();
})();
</script>
</head>
<title>Login Page</title>
<body onload="function()">
</body>
You won't be able to do this. Web applications cannot talk cross-origin to other web pages inside of a web browser.
Related
I am doing a small google script web app to update data from google sheet every 30 minutes. I've tried to use page refresh method but it is impossible because the web app show a blank page whenever refresh. So, is there any way to reload web app data periodically?
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.0/css/bootstrap.min.css">
<!-- jQuery library -->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
<!-- Latest compiled JavaScript -->
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.0/js/bootstrap.min.js"></script>
<meta http-equiv="refresh" content="1"> <!--this reload blank page-->
</head>
<body>
<div><b class="alert alert-danger">SẮP HẾT NHỰA</b>
</div>
<div class="ggsheetdata">
</div>
<script>
</script>
</body>
</html>
You can use the Javascript setInterval function to call a Javascript Function which in turn calls a google.script.run.withSuccessHandler(function(data){//update data here}).getData();
where getData() is a Google Apps Script function that returns the required data back the SuccessHandler.
However, your webapp must be able to be running in the browser at all times for this to work.
setInterval
I'm trying to use maps api (yandex but I have seen similar problem in google maps too) and include its script in head:
<!DOCTYPE html>
<html lang="en">
<head>
<title>site</title>
<meta charset="UTF-8">
<script src="https://cdnjs.cloudflare.com/ajax/libs/postscribe/2.0.8/postscribe.min.js">
<script async src="https://api-maps.yandex.ru/1.1/index.xml" type="text/javascript"></script>
<script type="text/javascript">
window.onload = function () {
var map = new YMaps.Map(document.getElementById("YMapsID"));
map.setCenter(new YMaps.GeoPoint(59.938518, 30.323342), 10);
};
</script>
</head>
Here is body:
<body>
<div class="map-block_map-item">
<div id="YMapsID" style="width:100%;height:100%">
</div>
</div>
</body>
But when page downloads I get this warning:
"It isn't possible to write into a document from an asynchronously-loaded external script unless it is explicitly opened."
If I don't use async attribute get this message:
A parser-blocking, cross site (i.e. different eTLD+1) script, https://api-maps.yandex.ru/1.1/_YMaps.js?v=1.1.21-58, is invoked via document.write. The network request for this script MAY be blocked by the browser in this or a future page load due to poor network connectivity. If blocked in this page load, it will be confirmed in a subsequent console message. See https://www.chromestatus.com/feature/5718547946799104 for more details
How can I solve this problem? As I understood it happens on very slow connections (but I have rather fast connection so why?) and it cause block document.written scripts. (I'm new in js so yes I have google it but didn't understand how it can be improve besides async script download)
As I am trying my hands on dojotoolkit, I try to run (open) following html code in my browser, as they said on tutorial, but my browser does not able to load dojo.js
At time of troubleshooting I found that source URL is converted like following:
file://ajax.googleapis.com/ajax/libs/dojo/1.10.4/dojo/dojo.js
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Tutorial: Hello Dojo!</title>
</head>
<body>
<h1 id="greeting">Hello</h1>
<!-- load Dojo -->
<script src="//ajax.googleapis.com/ajax/libs/dojo/1.10.4/dojo/dojo.js"
data-dojo-config="async: true"></script>
<script>
require([
'dojo/dom',
'dojo/dom-construct'
], function (dom, domConstruct) {
var greetingNode = dom.byId('greeting');
domConstruct.place('<em> Dojo!</em>', greetingNode);
});
</script>
</body>
</html>
Use a real webserver, rather than browsing from the filesystem.
While Frank is correct in that adding an explicit protocol to the URL will fix this particular issue, you are inevitably going to run into other issues anyway, such as XHR being locked down from the file:// protocol. The protocol-relative URL you were originally using will work fine if you test on a real webserver which serves http or https.
you need to add http as the protocol for the dojo.js file source.
<script src="http://ajax.googleapis.com/ajax/libs/dojo/1.10.4/dojo/dojo.js"
data-dojo-config="async: true"></script>
Also best practice is to add library files in the head tag instead of the body tag.
<head>
<meta charset="utf-8">
<title>Tutorial: Hello Dojo!</title>
<!-- load Dojo -->
<script src="//ajax.googleapis.com/ajax/libs/dojo/1.10.4/dojo/dojo.js"
data-dojo-config="async: true"></script>
</head>
I'm just building an experimental personal site where I could log myself into gmail with the press of a button.
Everithing goes fine, when I manually go to the gmail site and type the javascript command into the url line like this and press enter:
javascript: document.getElementsByName('Email').item(0).value='name'; document.getElementsByName('Passwd').item(0).value='password'; document.getElementsByName('signIn').item(0).click(); void(0);
But when I try to do the same from a page, nothing happens... Can someone please help me out?
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<title>Test</title>
<script>
var name = 'name';
function login(url1) {
win = window.open(url1, nome);
win.document.getElementsByName('Email').item(0).value='name';
win.document.getElementsByName('Passwd').item(0).value='password';
win.document.getElementsByName('signIn').item(0).click(); void(0);
}
</script>
</head>
<body>
<button id="buton1" onclick="login('https://accounts.google.com')">GMAIL LOGIN</button>
</body>
</html>
I've checked a lot of forums and answers, and it seemed that this method should work, but it doesn't.
Now imagine that your code was followed by similar code that would send lots of spam to people using your GMail account.
Cross domain DOM manipulation is forbidden by browsers as it would be a huge security hole.
The exception is postMessage, but that requires the cooperation of both sites.
You need a browser extension for this sort of thing.
<!DOCTYPE HTML>
<html>
<head>
<title>Doctor List</title>
<meta name="viewport" content="width=device-width,initial-scale=1"/>
<link rel="stylesheet" href="css/jquery.mobile-1.0rc1.min.css" />
<link rel="stylesheet" href="css/styles.css" />
</head>
<body>
<div id="employeeListPage" data-role="page" >
<div data-role="header" data-position="fixed">
<h1>Doctor</h1>
</div>
<div data-role="content">
<ul id="employeeList" data-role="listview" data-filter="true"></ul>
</div>
</div>
<script src="js/jquery.js"></script>
<script src="js/jquery.mobile-1.0rc1.min.js"></script>
<script type="text/javascript" src="http://panchoslimi.bugs3.com/MMC/js/DoctorList.js"></script>
</body>
Why scr="http://panchoslimi.bugs3.com/mmc/js/DoctorList.js" not working ? btw i need DoctorList.js on server side for my php file work. so i dont need doctorlist.js local on my xcode .. any solution ?
When I attempt to load the link repeatedly in a browser (drop it into the URL bar), the source code loaded once. On the other attempts, I get an error message:
Service Temporarily Unavailable
Speak with the person providing the JavaScript code about the server not being reliably available. You might see this behavior, for example, if they use load balancing and only some of their web servers are functioning correctly.
btw i need DoctorList.js on server side for my php file work. so i dont need doctorlist.js local
The code you show is HTML. HTML will execute in the client, not on the server. Your markup to include the script appears to be correct.
JavaScript does not run in PHP. To run it server-side, you need a server-side JavaScript engine.
Try to load your js from local. Just download it and include in your project like scr="/js/DoctorList.js".