stackblitz -> because its MIME type ('text/html') is not executable, and strict MIME type checking is enabled - stackblitz

I have created a simple JavaScript project in Stackblitz and trying to include
dropzone.js but getting below error message
(index):1 Refused to execute script from 'https://js-gxqqqw.stackblitz.io/dropzone.js' because its MIME type ('text/html') is not executable, and strict MIME type checking is enabled.
There are lot of similar posts but I could not find anything that is relevant to stackblitz.
Here is my stackblitz link : https://stackblitz.com/edit/js-gxqqqw
In-fact I am not able to include any other JS file using script tag.
<script type="text/javascript" src="Not_able_to_include_any_js_file.js"></script>

Changing the script tag to link tag with rel="preload" and as="script" attributes should fix the issue.
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8" />
<title>Title of the document</title>
<link rel="preload" href="dropzone.js" as="script" />
</head>
<body>
Content of the document......
</body>
</html>
Reference: https://developer.mozilla.org/en-US/docs/Web/HTML/Link_types/preload#including_a_mime_type

Related

sails.js and foundation 6 - TypeError: url.indexOf is not a function

I am trying to use sails.js and Zurb Foundation 6.2. I used this handy npm generator that sets up my grunt tasks. The output looks pretty good. I have a single js file that contains jquery, foundation, etc.
In my layout.ejs, I have this:
<!DOCTYPE html>
<html>
<head>
<title><%=typeof title == 'undefined' ? 'New Sails App' : title%></title>
<!-- Viewport mobile tag for sensible mobile support -->
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
<!--STYLES-->
<link rel="stylesheet" href="/styles/app.css">
<!--STYLES END-->
</head>
<body>
... some html ...
<%- body %>
<!--SCRIPTS-->
<script src="/js/dependencies/sails.io.js"></script>
<script src="/js/dependencies/foundation.js"></script>
<!--SCRIPTS END-->
<script>
$(document).foundation();
</script>
</body>
</html>
When I run the page, I get this error:
**TypeError: url.indexOf is not a function
jQuery.fn.load()
foundation.js:9612
<anonymous>
foundation.js:11913
<anonymous>**
My reading on this suggests that the issue is either that something is not be loaded, is being loaded more than once, or is in the wrong order. How do I narrow that down? I tried to use CDN's for each piece and still couldn't make it work.
Thank you for your help.
Foundation is not currently compatible with jQuery 3.0.0, Foundation is using the deprecated jQuery.fn.load(). Use jQuery 2.2.x for now. See issue and PR:
https://github.com/zurb/foundation-sites/issues/8834
https://github.com/zurb/foundation-sites/pull/8923

anchor tag with href as other than http is not working while sending mail to gmail

I am using the smtp sendmail function, in the anchor <a> tag href attribute we have reference other than http:// ie something like below
transauth://some other data
but the gmail is not creating the hyperlink of transauth but creating of http://gmail.com ,Any solutions regarding this.
Gmail strips links that use custom uri schemas.
A work around however is that if you have a website somewhere you can host a simple redirect page that will redirect you to the correct schema.
This is a pretty bullet proof redirect here I copied from this answer to another question
<!DOCTYPE HTML>
<html lang="en-US">
<head>
<meta charset="UTF-8">
<meta http-equiv="refresh" content="1;url=http://example.com">
<script type="text/javascript">
window.location.href = "http://example.com"
</script>
<title>Page Redirection</title>
</head>
<body>
<!-- Note: don't tell people to `click` the link, just tell them that it is a link. -->
If you are not redirected automatically, follow the <a href='http://example.com'>link to example</a>
</body>
</html>

Minimum includes for Alfresco Share custom page?

I am creating a custom Share page that must have none of the Alfresco UI on it, but which still needs access to the Alfresco and YAHOO objects.
I have successfully created the page and caused it to open in a new tab, but I get errors that the Alfresco and YAHOO objects are undefined.
What are the minimum includes I must add to my Freemarker template to get access to those objects?
Update: I have gotten the Alfresco and YAHOO objects to load, but now am getting "Uncaught Error: extend failed, please check that all dependencies are included."
Here are the freemarker and javascript includes I've got so far, if it'll help:
<#import "import/alfresco-common.ftl" as common />
...
<script type="text/javascript" src="../scripts/ajax/yahoo/yahoo-min.js"> </script>
<script type="text/javascript" src="../scripts/ajax/yahoo/connection/connection-min.js"> </script>
<script type="text/javascript" src="../scripts/ajax/common.js"> </script>
<script type="text/javascript" src="../scripts/ajax/utilities/utilities.js"> </script>
<script type="text/javascript" src="../yui/yuiloader/yuiloader.js"> </script>
<script type="text/javascript" src="../js/alfresco.js"> </script>
Update 2: Based on the first answer, the first few lines of the template look like this and again yield Uncaught ReferenceError: YAHOO is not defined:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<region-id>head-resources</region-id>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
<meta name="apple-mobile-web-app-capable" content="yes">
<title></title>
<script>
var urlParams;
Update 3: I've reduced the source to the minimum necessary to demonstrate the problem. What follows next is the template component definition file, followed by the freemarker template itself. Definition:
<?xml version='1.0' encoding='UTF-8'?>
<page>
<title>iPad Viewer</title>
<title-id>page.iPad.title</title-id>
<description>iPad Viewer</description>
<description-id>page.iPad.description</description-id>
<template-instance>viewer-ipad</template-instance>
<authentication>user</authentication>
</page>
Freemarker template:
<html>
<body>
<div class="content">
<#region-id>head-resources</#region-id>
<script>
alert(YAHOO);
alert(Alfresco);
</script>
</div>
</body>
</html>
Error is:
Caused by: freemarker.core.ParseException: Parsing error in template "org/alfresco/viewer-ipad.ftl" in line 11, column 7: Unclosed #... when the end of the file was reached.
I'm not sure how you created the page, but this is not needed when you define your regions.
Probably there are all in the <region-id>head-resources</region-id> So if you include that in the page-template that should suffice.

Favicon link does download instead of show

I have a favicon on my page, and when i go to the link for the favicon: mypage/favicon.ico
It starts download, instead of just showing it as an online image (as every other site).
I've searched everywhere for a solution, but got no answer.
I want it to show, and not to be downloaded, what can be the problem?
<head>
<link rel="shortcut icon" href="/favicon.ico">
</head>
Its an .ico file at 32x32.
Thanks - Chris
You can show it in HTML as a regular image tag. This has been tested in Firefox 26, Chrome 29 and Internet Explorer 10. All with positive results. You can try on your own browsers if you'd like.
Code:
<!DOCTYPE html>
<html>
<body>
<img src = "logo.ico" type = "image/x-icon">
</body>
</html>
You should use
<head>
<link rel="icon" href="/favicon.ico" type="image/x-icon" />
</head>
And consider to use another image e.g .png
<link rel="icon" href="/favicon.png" type="image/png" />
(Some Browsers does not support .ico)
If you call mypage/favicon.ico directly it might be dowloaded, depending on your http server/browser which mime type should be downloaded or displayed.
see Wikipedia.

Relative url automatic rewrite in asp.net MVC 2

ASP.net MVC 2 does rewrite all your relative urls in the <link> tag to the full relative path, which is good but it only works for URLs written in the <link> tag only, not <script> tags or any other elements.
Create an MVC 2 web application
create any controller and a view for it
inside the view create a <link> tag like this <link href="test.xml" type="text/css"/>
run your application, navigate to the view you created and then view source
you will find that MVC has rewritten your url in tag to full url like:
<link href="../Views/Home/Text.xml" type="text/css" />
i know that this file is in the Views folder and can't be viewed due to the web.config file that blocks any requests to files there, but thats not my problem
How can i get MVC to rewrite all urls not only in the <link> tage ?
Any help would be appreciated.
This happens because your <head> tag has a runat="server" attribute (a nasty heritage from WebForms). Remove it and no rewrites will happen. Also instead of:
<link href="test.css" type="text/css" />
you should always use Url helpers when dealing with urls:
<link href="<%= Url.Content("~/test.css") %>" type="text/css" />
You should not leave automatic rewrites to happen, always use Url.Content for linking static resources.
perhaps you have already tried something like this
<head runat="server">
<link href="test.xml" type="text/css"/>
<script src="<%= ((WebFormView)this.ViewContext.View).ViewPath.Substring(1,
((WebFormView)this.ViewContext.View).ViewPath.LastIndexOf('/')) %>test1.xml" type="text/javascript"></script>
</head>
renders html as
<head>
<link href="Views/Shared/test.xml" type="text/css" />
<script src="/Views/Home/test1.xml" type="text/javascript"></script>
</head>