jQuery works in FireFox, but not in Chrome with Google Sites Gadget - sites

Please excuse my ignorance, but I am totally new to jQuery, HTML, Javascript, and so on. Network backround.
I am inserting a html file into a Google Gadget for a Google site. What it is supposed to do is display 4 boxes that reveal a partial picture and a button to expand the picture. When you click on the button the box is supposed to enlarge and reveal the whole picture plus some text. This works fine in Firefox when I have this line:
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.5.1/jquery.min.js"></script>
but not in chrome.
I have uploaded all of these necessary files in order this to work in my Google Site to my Google Drive. I have shared the jQuery.js file in my drive and copied it to my html file. When I replace the line above with this line:
<script type="text/javascript" src="https://docs.google.com/a/chartwellreit.ca/uc?id=0B7EcQSX7GqjAREtlOXBOQmVRaUE"></script>
It works fine in Chrome, but not in FireFox.
Please let me know if you need anymore info.
Thanks!

https://developers.google.com/speed/libraries/devguide#jquery
To load a hosted library, copy and paste the HTML snippet for that library (shown below) in your web page. For instance, to load jQuery, embed this snippet:
<script src="//ajax.googleapis.com/ajax/libs/jquery/2.0.0/jquery.min.js"></script>
snippet in your web page.

Related

How can I scrape this page with selenium and chromedriver in python language?

I'm trying to scrape data from the website “http://www.nmpa.gov.cn/” by using selenium and chromedriver. When I was running the code, chromedriver succeeded in inputing the url but couldn't load the page, displaying a blank page. I tried to switch the target website into google.com and succeeded in scraping. I concluded that the target website server detected selenium and refused sending back data. So how can I scrape the data from website with selenium and chromedriver in python language. I'm quite a Python beginner, thank you for your kind help in advance. Here is my simple code:
from selenium import webdriver
my_driver_path = r"C:\python chrome driver\chromedriver.exe"
driver = webdriver.Chrome(executable_path=my_driver_path)
driver.get('http://www.nmpa.gov.cn/')
here is the photo of the issue:
enter image description here
The issue here is more on HTML than on Python.
If you check the source code of the page (you can do this by adding print(driver.page_source), you will see that it contains a meta tag with the http-equiv attribute set to "refresh":
<HTML><HEAD><title>NMPA</title></HEAD>
<body>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312"><meta http-equiv="refresh" content="0;URL=/WS04/CL2042/">
</HTML>
What this tag does is direct the browser to go to the given URL (/WS04/CL2042/, in a badly formatted attribute that the browser is luckily able to understand). So, instead of scraping http://www.nmpa.gov.cn/, you have to scrape http://www.nmpa.gov.cn/WS04/CL2042/.
If you change your code to access this other link, you will see that then you can get the whole page. You can either hard-code the new link or safely concatenate the first link with the "refresh" destination with a method like urllib.parse.join(): https://docs.python.org/3.7/library/urllib.parse.html#urllib.parse.urljoin.

Codename one: how to do live streaming

I want to display my webcams stream by typing his url in BrowserComponent of codeName one.
Since one week i'm trying to do it but my BrowserComponent display a plain text instead of image cam.
But if i'm trying in other standard browser like Firefox it works fine, i can cleary see my cam.
So I want to know if there is a solution to display liveStreaming with codeName one Browser.
If yes please where can I find a sample or and example ?
thanks
Your request can be implemented in a lot of several ways. I'm not sure that using the BrowserComponent is the best option, however the coding with BrowserComponent is quite simple.
First of all, you have to implement a web page on your domain that plays the video with a full cross-compatible HTML5 player. There are several commercial and free solution with different degrees of complexity and cost.
In my comment to your question, I mentioned "JWPlayer", however yesterday I've checked that (unfortunately) a JWPlayer free license like mine (that allows me to self-host the player) is not more available to the new users. To be more precise, following the launch of JW8 in October 2017, self-hosting the player is now only available to Enterprise customers.
However, to show you an easy solution, I registered a free 30 day trial account on DaCast, that provides a player for your videos on demand and for your live streamings. In the backend of DaCast, I uploaded a sample video and then I got the code to use the player, that is similar to the following (I obfuscated the id):
<script id="xxxxxx_x_xxxxxx" width="590" height="431" src="//player.dacast.com/js/player.js" class="dacast-video"></script>
Then that code can be integrated in a simple web page like the following (note that it will not work in local, you have to host it in your server):
<!doctype html>
<html lang="en">
<head>
<title>
</title>
<meta charset="UTF-8" />
</head>
<body>
<script id="xxxxxx_x_xxxxxx" width="590" height="431" src="//player.dacast.com/js/player.js" class="dacast-video"></script>
</body>
</html>
After that, you can create your BrowserComponent:
Form hi = new Form("Video test", new BorderLayout(BorderLayout.CENTER_BEHAVIOR_SCALE));
if (BrowserComponent.isNativeBrowserSupported()) {
BrowserComponent browser = new BrowserComponent();
browser.setURL("https://www.yourdomain.com/test.html");
hi.add(BorderLayout.CENTER, browser);
} else {
hi.add(BorderLayout.NORTH, "Your device is not supported");
}
hi.show();
I tested that this solution works on a real Android. Of course, this answer is only a tip for you and something that you can easily replicate and test, I'm not going to advertise any specific commercial service.
Another solution, using BrowserComponent.setURLHierarchy()
Create a folder named html and place it in the folder /src of your Codename One project. That means that your HTML5 player will be placed in an html file inside the folder /src/html. If you use Netbeans IDE, that folder will be shown as a package of your project.
Implement your player (for example in /src/html/player.html). As a suggestion, you can use the free open-source solution videojs-http-streaming + video.js: if you have done a right implementation, it should work with a browser. Note that you can add to /src/html/ all the files needed by the player.
In your app, use code similar to the following.
Code:
Form hi = new Form("Video player", new BorderLayout());
if (BrowserComponent.isNativeBrowserSupported()) {
BrowserComponent browser = new BrowserComponent();
browser.setURLHierarchy("/player.html");
hi.add(BorderLayout.CENTER, browser);
}
hi.show();
That's all. Of course the hardest part is to implement the HTML5 player: if your app can connect to the Internet, an easy solution can be the use of the CDNs, using the code samples provided in the linked pages of videojs-http-streaming.

Roboto based fonts not showing up in IE

I have an angular material application which when viewed in IE (11) doesnt display the fonts correctly. In Firefox and Chrome I dont see any problem.
The fonts are not being fetched remotely, they are contained as resources within the application.
As an example I have a sidenav component that holds a menu which looks like this in Chrome\Firefox:
But in IE looks like this:
Inspecting the network traffic in IE I can see the font files are being successfully retrieved and I can open these just fine when copying the urls into a new browser tab.
Oddly when I run protractor tests against IE, the fonts are rendering fine, I wonder if selenium server\IEdriver are doing something differently that allow the fonts to display?
Anyone got any ideas what could be the problem here?
Thanks

Loading angular in IE from file system

I have an angular app that has to be loaded from the file system, by IE, and will be shipped to clients (so I can't override security configurations)
The error I am getting has to do with trying to ng-include templates and getting an Error: Access is denied. in IE.
Searching the web, I found the perfect solution in the form of Mark of the Web.
I added <!-- saved from url=(0014)about:internet --> to the second line of my index.html, but that didn't remove the error.
I know another possible solution is to add all my templates as <script type="text/ng-template"> and load them from the templateCache, but this will be a large app and I don't want to have all my html written in one file.
Is there anything i'm missing? Any possible solution? Why is my MOTW tag not working? Appreciate any idea, i'm desparate!
Thanks,
Uri

Google plus one button not showing

I'm trying to add a Google +1 button to my website.
I have followed the instructions here:
http://www.google.com/intl/en/webmasters/+1/button/index.html
This the code for my webpage:
<html>
<head>
<title>
Why won't it appear?
</title>
<!-- Place this tag in your head or just before your close body tag -->
<script type="text/javascript" src="https://apis.google.com/js/plusone.js"></script>
</head>
<body>
<h1>
Example title
</h1>
<!-- Place this tag where you want the +1 button to render -->
<g:plusone size="tall" href="http://www.example.com/"></g:plusone>
</body>
</html>
As you can see, I've followed their instructions exactly, and yet it does not appear. I've tried it on Chrome, Firefox and IE8 (all on Windows XP). I'm just opening the webpage from my local system.
Interestingly I can see it working here http://www.satinbow.co.uk/xxtest.html
Can anyone solve the mystery?
Update / clues
When the page is stored on my system locally, it doesn't work (hard refreshing didn't fix it either.)
But I've put the page here: dl.dropbox.com/u/6920023/test2.html and it seems to work there.
It would be really cool know what's going on :)
I think it's because when it's local (not webserver) browser block the JS script (that's hosted externally) to prevent security breach. That's why it doesn't work
Link: http://ejohn.org/blog/tightened-local-file-security/
Another thing to check for is whether you have any ad blockers active. These can disable the +1 button and move the iframe containing the button out of the screen.
Working on my open source project, http://code.google.com/p/gwt-socialmedia,
i have discovered another reason that can cause the +1 button not to render: You forgot to define the "URL to +1": It must be a valid URL to an accessible website (so http://localhost won't work for i.e.).
Indeed, the PlusOne API seems to connect to the site URL, in order to get some metadata about it (like the description, title, etc)
If you don't define the URL, Google will send you an error HTTP 400 (Bad Request), with the internal message : "The requested URL was not found on this server. "
and the button will not appear...
Hope it helps!
Due to browser security(as mentioned in one of the answer) it would not display the button. Still to display google plus buttons when your file is local use local web server(WAMP/XAMPP) or you may use PHP local server https://www.sitepoint.com/taking-advantage-of-phps-built-in-server/ to host your file on your computer and you will see the button displayed in your file.

Resources