SSRS Report Viewer Control Browser Compatibility - reporting-services

How compatible is the MS Report Viewer Control with browsers like Firefox and Safari?
Please also post if you know any 3rd party report viewers for SSRS.

Edit - 2016/2017 Update
SSRS 2016+ can be said to be cross-browser compatible.
Table borders aren't displaying right in IE10, but IE10 is dying out anyway.
In the rest of the browsers, it's fine.
You still need to register add_pageLoaded to translate the parameter prompts.
Sys.WebForms.PageRequestManager.getInstance().add_pageLoaded(function () { fixReportingServices('rpt-container'); });
Also, like in versions < 2016, you need to add PageCountMode="Actual" to RS:ReportViewerHost control.
<RS:ReportViewerHost ID="ReportViewerControl" PageCountMode="Actual" runat="server" />
if you want to have meaningful paging numbers.
Also, there's a problem when you set the language in the query string with datepickers (with SSRS < 2016 as well). You need to set context.Request.UserLanguages[i] to the language specified in the query-string in context.BeginRequest in a HTTP-Module, if you want datepicker to work with a non-browser language.
Also, you need to add the X-Frame-Options and Content-Security-Policy HTTP-headers in each HTTP-response, if you want to use SSRS in an iframe in the internet securely. See my github-repository for details.
</EndEdit>
Pre-2016:
I can tell you, I have 9 years experience with the damn thing (SSRS 2005, SSRS 2008 R1 & R2, 2012, and SSRS 2014).
Let me assure you that because SSRS HTML reports depend on IE5-Quirksmode, there is no chance in hell they will ever render correctly in any browser other than Internet Explorer (IE < 10 I might be inclined to add).
IF you have admin access to the reportserver, and I stress the IF, you can add jQuery routines and CSS on the ReportViewer page to correct the most basic problems (like that you don't see more than 1cm of the report), but otherwise, the HTML rendering will still look absolutely horrible (margins, table borders, picture paddings, column size, textfield-size, title and/or pagenumber-alignment, etc., in short - just about anything)
Of course, the ActiveX printer control can only ever work in InternetExplorer (on Windows), because only there ActiveX are supported.
Let me also assure you, there is absolutely no way in hell to get ReportManager working in any other browser than IE.
As for Internet Explorer support, it should be mentioned, that starting as of IE version 10, IE defaults to webkit-quirksmode (for compatibility reasons) instead of IE5 quirksmode, so the HTML rendered will look equally horrible as in Chrome/Firefox/Safari for IE 10+, unless you added meta xua-compatible IE5 in the ReportViewer.aspx page.
The latter might not apply for Intranet, as IE automatically falls back to IE 7 compatibility mode when it's on an intranet site (but only in any Windows version < 8).
In Windows 8, localhost links and computername links (can't add the http:// in stackoverflow posts) are not assigned to the local intranet zone (probably as quick hack so IE doesn't fall back to IE7 compatibility mode), and therefore, Windows authentication will FAIL.
It should also be mentioned that it's not possible to add meta xua-compatible IE5 for ReportManager, because there is no page you can edit (compiled non-updateable ASP.NET website-project... ).
And that short of using the dev-tools to switch reportmanager in quirksmode, it's not possible to use ReportManager in IE 10+.
Then, another thing to mention is, that starting as of IE9, IE inherits the doctype of iframe elements from the parent page, and there is no way in hell to change that either (without changing the parent page to the desired child-page doc-mode).
So if you were clever enough to use iframes for the reports, because there is no way in hell any sane person wants popups in the age of popup-blockers, the report page will inherit the parent page's doctype. If that isn't IE5-QuirksMode, it will render the reports equally horrible as on Safari/Chrome/Firefox/Opera for any IE > 8, irrespecive of any possible meta xua-compatible ie5 tag in ReportViewer.aspx.
As for alternatives, for free and with a similar feature-set, there is only Eclipse BIRT (fortunately, the HTML rendering isn't similar).
It should be mentioned that BIRT, although licensed under the Eclipse Public License, uses SUN Java and therefore you are using Oracle technology, which is subject to its respective licensing terms.
Also, you are using non-Microsoft technology, and the Excel-Sheets BIRT renders are actually XML files, which will produce (who would have guessed) a rather alarming warning when opening in Office 2010+.
Then, for a rather large fee, there is http://www.stimulsoft.com reports, and Telerik reports.
From the technical looks of it, I'd recommend stimulsoft reports, but: disclaimer, i haven't used either of these, because they aren't free.
As for alternative SSRS rendering engines (not viewers btw), there is only www.fyireporting.com/‎, which has a fork here http://www.codeproject.com/Articles/138271/An-Open-Source-RDL-Engine.
But fyiReporting is incomplete and work in progress (if not abandoned), so I would refrain from using it.
Bottom line, if your product is IE & windows only, with windows version < 8 (and no - not <= just in case you haven't been paying attention), in intranet, called from pop-ups and not iframes, then go with SSRS.
For anything else, use stimulsoft reports (the problem is, you have to redo all your reports, as there is no automated migration - not even a non-working one).
PS:
And by adding "a little javascript", i mean the below thing(2008 R1 Edition, won't work on 2008R2+, may work on 2005, and note that you need to embed jQuery and jQuery Migrate in an inline-script tag, if the client PC's don't have access to http(s)://ajax.aspnetcdn.com [note: putting the scripts into the Pages folder and adding a relative or absolute link won't work...]):
<%# Register TagPrefix="RS" Namespace="Microsoft.ReportingServices.WebServer" Assembly="ReportingServicesWebServer" %>
<%# Page Language="C#" AutoEventWireup="true" Inherits="Microsoft.ReportingServices.WebServer.ReportViewerPage" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<%= System.Web.HttpContext.Current.Request.Browser.Browser == "IE" && System.Globalization.CultureInfo.InvariantCulture.CompareInfo.IndexOf(System.Convert.ToString(System.Web.HttpContext.Current.Request.QueryString), "stylesheet", System.Globalization.CompareOptions.IgnoreCase) == -1 ? (System.Web.HttpContext.Current.Request.Browser.Browser != "IE" ? "": "<meta http-equiv=\"X-UA-Compatible\" content=\"IE=5\">") : "<meta http-equiv=\"X-UA-Compatible\" content=\"IE=edge,chrome=1\">" %>
<head id="headID" runat="server">
<title>Report Viewer</title>
<script type="text/javascript" src="//ajax.aspnetcdn.com/ajax/jQuery/jquery-1.9.1.min.js"></script>
<script type="text/javascript" src="//ajax.aspnetcdn.com/ajax/jquery.migrate/jquery-migrate-1.1.0.min.js"></script>
<script type="text/javascript">
var bInFrameOrIframe = false;
var iLanguageIndex = 0;
var language = "DE_LOL";
var UpdateLock = false;
if (window.self === window.top) {
// alert("true");
// not in a frame
// Use IE5 quirksmode
//document.writeln('<meta http-equiv="X-UA-Compatible" content="IE=5" />');
bInFrameOrIframe = false
}
else {
// in a frame, FMS
bInFrameOrIframe = true;
}
function TranslateParameterPrompts() {
//mTo = false;
$("table[id^='ParametersGridReportViewerControl'] span").each(function(index) {
var strText = $(this).text();
if (strText != null && strText.indexOf('/') != -1) {
strText = strText.split('/');
if (iLanguageIndex < strText.length)
strText = strText[iLanguageIndex];
else {
if (strText.length > 0)
strText = strText[0];
}
$(this).text(strText);
}
});
//setTimeout(function(){mTo = true}, 5000);
}
function setTableSize() {
//$("[id$='ReportViewerControl']")
$(
$(
$("#ReportFrameReportViewerControl")[0].contentWindow.document
)
.find("[id$='report']")[0].contentWindow.document.body
).find('*')
.each(function() {
//console.log("Processing an element");
//var cls = $(this).attr("class");
try {
// Don't add a border to sort-arrow
if ($(this).is('img')) {
return;
}
var anywidth = $(this).css('width');
var anywidth = parseFloat(anywidth);
//console.log("anywidth: " + anywidth);
//var lol = $(this).css('borderLeftWidth');
var blw = $(this).css('border-left-width');
var brw = $(this).css('border-right-width');
var btw = $(this).css('border-top-width');
var bbw = $(this).css('border-bottom-width');
var borls = $(this).css('border-left-style') == "solid";
var borrs = $(this).css('border-right-style') == "solid";
var borts = $(this).css('border-top-style') == "solid";
var borbs = $(this).css('border-bottom-style') == "solid";
var blw = parseFloat(blw);
var brw = parseFloat(brw);
var btw = parseFloat(btw);
var bbw = parseFloat(bbw);
//parseInt($(this).css("borderRightWidth"))
//console.log(parseInt($(this).css("borderLeftWidth")));
UpdateLock = true;
// Set width to 1px where 0px
if (anywidth == 0)
$(this).css('width', '1px');
if (borls && blw == 0.0 || (blw > 0.0 && blw < 1.0)) {
//console.log("setting border width");
$(this).css('border-left-width', '1px');
}
if (borrs && brw == 0.0 || (brw > 0.0 && brw < 1.0)) {
$(this).css('border-right-width', '1px');
}
if (borts && btw == 0.0 || (btw > 0.0 && btw < 1.0)) {
$(this).css('border-top-width', '1px');
}
if (borbs && bbw == 0.0 || (bbw > 0.0 && bbw < 1.0)) {
$(this).css('border-bottom-width', '1px');
}
UpdateLock = false;
}
catch (ex) {
UpdateLock = false;
//console.log(ex);
}
}); // End $('*').each
// console.log("loop");
var $img = $("img[onload^='this.fitproportional=true']");
if ($img == null) {
// console.log("img is null");
return;
}
var $div = $img.parent();
if ($div == null) {
// console.log("div is null");
return;
}
UpdateLock = true;
{
$img.removeAttr("height");
$img.css('max-width', '100%')
$img.css('max-height', '100%')
$div.css('text-align', 'right');
var divMinWidth = parseFloat($div.css('min-width'));
var divWidth = parseFloat($div.css('width'));
var divMinHeight = parseFloat($div.css('min-height'));
var divHeight = parseFloat($div.css('height'));
// console.log("width: " + divWidth);
// console.log("height: " + divHeight);
// console.log("min-width: " + divMinWidth);
// console.log("min-height: " + divMinHeight);
if (divMinWidth != 0)
$div.css('width', $div.css('min-width'));
if (divMinHeight != 0)
$div.css('height', $div.css('min-height'));
}
UpdateLock = false;
}
$(document).ready(function() {
switch (language) {
case "fr":
iLanguageIndex = 1;
break;
case "it":
iLanguageIndex = 2;
break;
case "en":
iLanguageIndex = 3;
break;
default: // "DE"
iLanguageIndex = 0;
}
TranslateParameterPrompts();
// setInterval(function() { TranslateParameterPrompts() }, 100);
if ($.browser.msie && !bInFrameOrIframe)
return;
// if ($.browser.webkit)
//setTableSize();
$("[id$='ReportFrameReportViewerControl']").load(function() {
//setNewHeight();
//alert("Loading");
setTableSize();
$(
$("[id$='ReportFrameReportViewerControl']")[0].contentWindow.document
)
.find("[id$='report']").load(function() {
//alert("load report");
setTableSize();
}
); // End load #report
}); // End Function load #ReportFrameReportViewerControl
}); // End Function document.ready
</script>
</head>
<body style="margin: 0px; overflow: auto">
<form style="width:100%;height:100%" runat="server" ID="ReportViewerForm">
<RS:ReportViewerHost ID="ReportViewerControl" runat="server" />
</form>
</body>
</html>
Note: UpdateLock stems from 2012 backport and is not really used here, and language stems from backport too, setInterval on TranslateParameterPrompts is necessary in 2012
and function
for 2012 has only the little addition of "label" in the jQuery selector...
function TranslateParameterPrompts() {
//mTo = false;
$("table[id^='ParametersGridReportViewerControl'] label span").each(function(index) {
var strText = $(this).text();
if (strText != null && strText.indexOf('/') != -1) {
strText = strText.split('/');
if (iLanguageIndex < strText.length)
strText = strText[iLanguageIndex];
else
{
if(strText.length > 0)
strText = strText[0];
}
$(this).text(strText);
}
});
//setTimeout(function(){mTo = true}, 5000);
}
Infering the language from the browser language goes like this, btw:
<script type="text/javascript">
language = <%= System.Web.HttpContext.Current.Request.UserLanguages != null ? "\"" + System.Convert.ToString(System.Web.HttpContext.Current.Request.UserLanguages[0]) + "\"" : "null" %>;
if(language == null)
language = window.navigator.userLanguage || window.navigator.language;
if(language != null)
language = language.substr(0,2).toLowerCase();
</script>
And in 2012 you need to Dispose of the session cookies, otherwise you get "HTTP 400: Header too long" after opening about 120 reports:
<script type="text/C#" runat="server">
protected string ClearSessionKeepAliveCookiesToPreventHttp400HeaderTooLong()
{
if(Request == null || Request.Cookies == null)
return "";
if(Request.Cookies.Count < 60)
return "";
// System.Web.HttpContext.Current.Response.Write("<h1>"+Request.Cookies.Count.ToString()+"</h1>");
for(int i = 0; i < System.Web.HttpContext.Current.Request.Cookies.Count; ++i)
{
if(StringComparer.OrdinalIgnoreCase.Equals(Request.Cookies[i].Name, System.Web.Security.FormsAuthentication.FormsCookieName))
continue;
if(!Request.Cookies[i].Name.EndsWith("_SKA", System.StringComparison.OrdinalIgnoreCase))
continue;
if(i > 60)
break;
//System.Web.HttpContext.Current.Response.Write("<h1>"+Request.Cookies[i].Name+"</h1>");
System.Web.HttpCookie c = new System.Web.HttpCookie( Request.Cookies[i].Name );
//c.Expires = System.DateTime.Now.AddDays( -1 );
c.Expires = new System.DateTime(1970, 1 ,1);
c.Path = Request.ApplicationPath + "/Pages";
c.Secure = false;
c.HttpOnly = true;
// http://stackoverflow.com/questions/5517273/httpcookiecollection-add-vs-httpcookiecollection-set-does-the-request-cookies
//Response.Cookies[Request.Cookies[i].Name] = c;
//Response.Cookies.Add(c);
Response.Cookies.Set(c);
}
return "";
}
</script>
And on 2012, you need to listen to content update, because it uses Microsoft Ajax controls
function cbOnContentUpdate() {
//console.log("content update");
alterTableBorderWidth();
// TranslateParameterPrompts();
} // End Callback cbOnContentUpdate
var hLastTimeout = null;
function queueUpdate() {
if (UpdateLock)
return;
if (hLastTimeout != null)
clearTimeout(hLastTimeout);
hLastTimeout = window.setTimeout(function() { cbOnContentUpdate(); }, 50);
//window.setTimeout(function() { cbOnContentUpdate(); }, 3000);
} // End Function queueUpdate
$(document).ready(function() {
switch (language) {
case "fr":
iLanguageIndex = 1;
break;
case "it":
iLanguageIndex = 2;
break;
case "en":
iLanguageIndex = 3;
break;
default: // "DE"
iLanguageIndex = 0;
}
setInterval(function() { TranslateParameterPrompts() }, 100);
// opt-out for non-framed IE, because that crook supports IE5-Quirks (framed takes parent-doctype in IE >= 9)
if ($.browser.msie && !areWeInFrame())
return;
// if ($.browser.webkit)
// console.log('Setting event listener!');
// http://stackoverflow.com/questions/4979738/fire-jquery-event-on-div-change
//$("[id$='ReportViewerControl']").bind('DOMNodeInserted DOMNodeRemoved', function(event) {
//$("[id$='ReportArea']")
$("body")
.bind('DOMNodeInserted DOMNodeRemoved DOMSubtreeModified', function(event) {
if (event.type == 'DOMNodeInserted') {
//console.log('Content added! Current content:' + '\n\n' + this.innerHTML);
//console.log('Content added!');
queueUpdate();
}
else {
//console.log('Content removed! Current content:' + '\n\n' + this.innerHTML);
//console.log('Content removed!');
queueUpdate();
}
}); // End Bind IRM
}); // End Function $(document).ready
And note that for 2012, setTableSize is alterTableBorderWidth, and the selector goes like this:
function alterTableBorderWidth()
{
//$('*')
$("[id$='ReportViewerControl']").find('*')
.each(function() {
Btw, if you want to remove the PRINT icon, because it's only a source of sorrow, that goes like this (for German, English, French and Italian [the languages spoken in Switzerland + English]).
This CSS is for 2008 R1, don't know and care if it's the same in 2012.
input[type="image"][title="Drucken"], input[type="image"][title="Print"], input[type="image"][title="Imprimer"], input[type="image"][title="Stampa"]
{
display: none !important;
}
And if that still doesn't deter you, then go right ahead and use forms authentication in SSRS 2012 (hint 1: there is no ms-provied sample as for 2005-2008R2, you need to write it yourself) ;)
Hint2: if you followed hint1, forms authentication redirect doesn't work when you have a colon in the URL [bug?], you can steal the code from mono and write your own redirect.
Hint3: if you followed hint2 and got forms authentication working, then you probably want to change the upload tool you're going to write, because you won't like to do manually "for each report browse-directory - check allow override checkbox - upload report - set datasource) for 120 reports or so, then you will be inheriting a class from ReportingService2005 and override GetWebRequest and GetWebResponse
''' <summary>
''' Overriding the method defined in the base class.
''' </summary>
''' <param name="uri"></param>
''' <returns></returns>
Protected Overrides Function GetWebRequest(uri As Uri) As System.Net.WebRequest
Dim request As System.Net.HttpWebRequest
request = DirectCast(System.Net.HttpWebRequest.Create(uri), System.Net.HttpWebRequest)
request.Credentials = MyBase.Credentials
request.CookieContainer = New System.Net.CookieContainer()
If m_authCookie IsNot Nothing Then
request.CookieContainer.Add(m_authCookie)
End If
Return request
End Function ' GetWebRequest
''' <summary>
''' Overriding the method defined in the base class.
''' </summary>
''' <param name="request"></param>
''' <returns></returns>
Protected Overrides Function GetWebResponse(request As System.Net.WebRequest) As System.Net.WebResponse
Dim response As System.Net.WebResponse = MyBase.GetWebResponse(request)
' http://social.msdn.microsoft.com/Forums/sqlserver/en-US/f68c3f2f-c498-4566-8ba4-ffd5070b8f7f/problem-with-ssrs-forms-authentication
Dim cookieName As String = response.Headers("RSAuthenticationHeader")
If cookieName IsNot Nothing Then
m_authCookieName = cookieName
Dim webResponse As System.Net.HttpWebResponse = DirectCast(response, System.Net.HttpWebResponse)
Dim authCookie As System.Net.Cookie = webResponse.Cookies(cookieName)
' Save it for future reference and use.
m_authCookie = authCookie
End If
Return response
End Function ' GetWebResponse
Hint 4: The above methods won't work if you haven't installed service pack 1 + 2 on SSRS 2008 R2...
Hint 5: The TranslateParameters method is there because you cannot (by design) translate the parameter prompts to multiple languages by SSRS, so you write:
Raum / Local / Locale / Room
which uses schema:
Text_DE / Text_FR / Text_IT / Text_EN
And then do split by '/' on the text (which is a little error prone if your prompt text contains '/' somewhere), and then select the right text by index of the language, by choosing MIN(splitarray.length, index) btw, just in case somewhere you only have Text_DE / Text_FR or whatever, first checking if the text contains a '/' at all, of course.
Hint 6:
Need I go on ? (i could still expand this post to tenfold size, but I think I should go back to work now :) )
If you want to see just how f*up it looks, this is how vanilla ssrs renders in chrome
This is what it looks like in IE11, with IE5 compatibility set via xua
And this is what it should be, and what you can get it to render with much tinkering with javascript and CSS
Addendum:
Oh, and it gets even better
If you want to run reportviewer in a language specified by your application (which is NOT identical to the browser language), you need to set the culture of reportviewer to the culture specified in your query string...
<script type="text/C#" runat="server">
protected override void InitializeCulture()
{
string sprache = System.Web.HttpContext.Current.Request.QueryString["in_sprache"];
// System.Web.HttpContext.Current.Response.Write(sprache);
switch(System.Globalization.CultureInfo.InvariantCulture.TextInfo.ToLower(sprache))
{
case "fr":
sprache = "fr-CH";
break;
case "it":
sprache = "it-CH";
break;
case "en":
sprache = "en-US";
break;
default:
sprache = "de-CH";
break;
}
// System.Web.HttpContext.Current.Response.Write(sprache);
System.Threading.Thread.CurrentThread.CurrentCulture = System.Globalization.CultureInfo.CreateSpecificCulture(sprache);
System.Threading.Thread.CurrentThread.CurrentUICulture = new System.Globalization.CultureInfo(sprache);
base.InitializeCulture();
}
</script>
If you want to set a static culture, you can do so in the page declaration
<%# Page UICulture="de" Culture="de-CH" %>
And if you try to remove the the print icon and the atom-feed, doing it with styles, no matter how, it only works in Chrome...
input[type="image"][title="Drucken"], input[type="image"][title="Print"], input[type="image"][title="Imprimer"], input[type="image"][title="Stampa"]
{
display: none !important;
}
input[type="image"][title="In Datenfeed exportieren"], input[type="image"][title="Exporter vers un flux de données"], input[type="image"][title="Esporta in feed di dati"], input[type="image"][title="Export to Data Feed"]
{
display: none !important;
}
*/
input[type="image"][src$="Microsoft.Reporting.WebForms.Icons.Print.gif"] {
display: none !important;
}
input[type="image"][src$="Microsoft.Reporting.WebForms.Icons.AtomDataFeed.gif"] {
display: none !important;
}
But you can actually remove at least the print icon in internet-explorer by adding ShowPrintButton="false" to the reportviewer control:
<RS:ReportViewerHost ID="ReportViewerControl" ShowPrintButton="false" runat="server" />
Another idea: in SSRS 2012 & 2014 (and possibly 2008R2), you can also add your SSRS-fixing javaScript method into add_pageLoaded of ScriptManager. Like this:
Sys.WebForms.PageRequestManager.getInstance().add_pageLoaded(function () { fixReportingServices('rpt-container'); });
Then you don't have to listen to page change events, which speeds things up, because loaded is only called once at the end of each update.
WARNING
Because in the Internet, IE doesn't default to compatibility view,
<meta http-equiv="X-UA-Compatible" content="IE=5">
won't help you with certain issues either (rotate270 text/vertical text).
Even in IE, it only works properly when you are in the intranet, because only then it uses "compatibility view". While the meta-tag sets the brower into IE5-Quirksmode, it doesn't enable "compatibility view", so it isn't the true quirksmode...

MS Report Viewer Control will work fine in IE only.
You can see the Reports from other browsers but you cannot able to view Zoom Option

See the following MSDN articles for browser compabilities and the ReportViewer controls:
Browser Support for ReportViewer Web Server Controls
Browser Support in Reporting Services

I have not noticed any real issue with it being displayed in Firefox or Safari. At times I think it might be getting rendered better in Firefox, but I don't have any actual benchmarks to back that up.

From the hip and perhaps a little stale. ASP.NET used to treat any non IE browser as a box of rocks. May be worth looking into if your experience problems.
http://weblogs.asp.net/fmarguerie/archive/2005/01/04/346222.aspx

SSRS works perfectly on IE6,7,8. It works on Firefox and Safari, but with displaying issues.
There are two possible solutions to fix those, test and see whichever works for you.
Solution 1
Go to
C:\Program Files\Microsoft SQL
Server\MSSQL.(your report server
instance)\Reporting
Services\ReportServer\Pages\reportviewer.aspx
Update style as
<body style="margin: 0px; overflow: auto"> ... <RS:ReportViewerHost style="display:table;" ID="ReportViewerControl" runat="server" />
Solution 2
Add following changes to stylesheet:
.DocMapAndReportFrame { min-height: 660px; min-width: 1280px; }
.MenuBarBkGnd { min-width:1000px; }

Rendering issues exist with Firefox, Chrome and Safari. I know for Firefox and Chrome, there are IE Add-ins that allow you to run the report in a Firefox/Chrome tab.

Related

How to (hack and) maximize Google Doc's Drawing Window to full screen?

Friends of the Internets,
Google Docs's Intert Drawing tool works, except for the fact that it wastes half of all 16:9 screens, since it opens a forced-square window that is UNRESIZABLE, cripling all drawings that are intended for LANDSCAPE and/or PORTRAIT format! Think of all the standard formats like A4, A3, 16:9 monitors.
I've been asking this quetsion to super users, to no avail. NOBODY seems to know the answer! I'm resorting to skilled programmers to hack our way into this and am planning on opening a bounty worth 500 as soon as this this becomes available for this question! This is an essential yet overlooked potential portion of Google Docs that has been overlooked.
Any and all solutions that make this work in Google's own browser Chrome will be:
Awarded 500 bounty points
Accepted as answer
I think the simplest way is make a Chrome Extension Plugin for solve this problem. I made an example of how you should work, of course, a rudimentary but for the purpose is ok. Check it on github (Download the zip, unpack, go to chrome extensions and => "Load unpacked", enjoy :D). For more complex solutions you need to use google document api.
Example of code
document.addEventListener('DOMContentLoaded', function () {
let fullScreenBtn = document.getElementById('fullScreenBtn');
fullScreenBtn.onclick = function (element) {
function modifyDOM() {
function setToFullScreen(iteration, drawer) {
drawer.style.left = '0';
drawer.style.top = '0';
drawer.style.borderRadius = '0';
drawer.style.width = '100%';
drawer.style.height = '100vh';
document.getElementsByClassName('modal-dialog-content')[iteration].style.height = '100vh';
var iframe = drawer.getElementsByTagName("IFRAME")[0]
iframe.width = '100%';
iframe.height = '100%';
var canvas = iframe.contentWindow.document.getElementById('canvas-container');
canvas.style.borderLeft = 'solid 2px red';
canvas.style.borderRight = 'solid 2px red';
}
var drawers = document.getElementsByClassName('modal-dialog');
let drawerCount = drawers.length;
if (drawerCount) {
for (let i = 0; i < drawerCount; i++) {
setToFullScreen(i, drawers[i]);
}
} else {
alert('First off all open the drawer!')
}
return document.body.innerHTML;
}
chrome.tabs.query({ active: true }, function (tabs) {
var tab = tabs[0];
chrome.tabs.executeScript(tab.id, {
code: '(' + modifyDOM + ')();'
}, (results) => {
// console.log(results[0]);
});
});
};
If you want, you can resize the drawing canvas also, but if you do, it make some bugs (like #Anthony Cregan said) ...
You can do with changing the code in this section
var canvas = iframe.contentWindow.document.getElementById('canvas-container');
canvas.style.left = '0';
//canvas.style.position = ''; // works but in resizing elemnts bug
canvas.style.minWidth = '100%';
In action
I acheived this by opening in chrome, pressing F11 (fullscreen), F12 (console). I then navigated the dom in the Elements tab to:
#canvas-container
then set the element styles manually
left: 41px
width: 1787px
EDIT: unfortunately subsequent edits seem to reset the styles you enter manually, there may be a way to enforce these after subsequent draw actions but for now this solution is only good for displaying the end result, not drawing full-screen.
EDIT EDIT: you can enforce these by adding them to the element in the styles sidebar and maintain them with !important but this causes the draw functions to lose their co-ordinates (pen tool draws away from the pointer along the x-axis for instance).
Boom! As you said it's a hack. But this works:
F12->Console->Paste->Enter
let modal = document.getElementsByClassName("sketchy-dialog")[0];
modal.style.width="100%";
modal.style.height="100%";
modal.style.left="0px";
modal.style.top="0px";
let content = document.getElementsByClassName("modal-dialog-content")[0];
content.style.height="100%";
let iframe;
let iframes = document.getElementsByTagName("iframe");
for(let x=0;x<iframes.length;x++)
{
let elem = iframes[x];
if(elem.src.startsWith("https://docs.google.com/drawings"))
{
iframe = elem;
}
}
iframe.style.width="100%";
iframe.style.height="100%";
I use this simple “hack” from console. Just open the drawing modal > press F12 > Click Console > and paste this following js.
modal = document.getElementsByClassName('modal-dialog');
frame = modal[0].getElementsByTagName('iframe');
modal[0].style.width = window.innerWidth+"px";
modal[0].style.height = window.innerHeight+"px";
modal[0].style.top = 0;
modal[0].style.left = 0;
frame[0].width = window.innerWidth;
frame[0].height = window.innerHeight;

Setting a hotkey in my asp.net application

I am trying to set a keyboard shortcut in my application to click an actionlink that I currently have. I would like to set "+" as the key. I have tried setting the accesskey to "+", but that would only select the link and not click it. It also only worked for the plus symbol at the top of the keyboard and didn't work for the plus symbol on the num pad.
My current solution:
#Html.ActionLink("Create New", "Create", null, new { accesskey = "+" })
In conclusion, I would like to use the plus on the numpad and I would like the hotkey to click the link instead of just highlighting it.
Thanks
Edit:
I now realize that it was just IE that was working this way for accesskeys and that once I used Chrome, it worked perfectly. I normally use Chrome, but I was using IE for debugging.
In a project I use JavaScript to do what you need:
<script language="javascript" type="text/javascript">
document.onkeydown = function (evt) {
var isIE = (document.all ? true : false);
evt = evt || window.event;
switch (evt.keyCode) {
case evt.altKey && 49:
mod(document.getElementById("<%= mod01.ClientID%>"));
break;
case evt.altKey && 97:
mod(document.getElementById("<%= mod01.ClientID%>"));
break;
case evt.altKey && 51:
mod(document.getElementById("<%= mod03.ClientID%>"));
break;
}
};
The elements are asp hyperlinks:
<asp:HyperLink ID="mod03" Text="Example" CssClass="d9"
runat="server"> </asp:HyperLink>

How to hide the source code of a HTML page

I created an HTML page and now would like to hide the source code and encrypt it.
How can I do that?
You can disable the right click, but that's a bad idea because expert minds can read anything from your page.
You cannot totally hide the page source - this is not possible. Nothing is secure enough on the Internet.
In any case, you can encrypt it and set a password.
You can utilise this link - it will encrypt your HTML page with a password.
First up, disable the right click, by writing out this script, right after the tag.
<SCRIPT language=JavaScript>
<!-- http://www.spacegun.co.uk -->
var message = "function disabled";
function rtclickcheck(keyp){ if (navigator.appName == "Netscape" && keyp.which == 3){ alert(message); return false; }
if (navigator.appVersion.indexOf("MSIE") != -1 && event.button == 2) { alert(message); return false; } }
document.onmousedown = rtclickcheck;
</SCRIPT>
Then, encrypt all of it, in this website, called 'AES encryption'.
Link - http://aesencryption.net/
You need to set a password to decrypt it ....you choose the password.
After encrypting it, you can just write a basic HTML page just putting into the <head> tag once again the script to disable the right click, into the <body> tag you code and hide everything just writing at top of the page <html hidden>.
Example
<!DOCTYPE html>
<html hidden>
<head>
<SCRIPT language=JavaScript>
<!-- http://www.spacegun.co.uk -->
var message = "function disabled";
function rtclickcheck(keyp){ if (navigator.appName == "Netscape" && keyp.which == 3){ alert(message); return false; }
if (navigator.appVersion.indexOf("MSIE") != -1 && event.button == 2) { alert(message); return false; } }
document.onmousedown = rtclickcheck;
</SCRIPT>
</head>
<body>
--here, you put the encrypted code from the link above--
</body>
</html>
Where it is written var message = "function disabled"; you can write for example something like 'This page cannot be viewed' or something which will annoy most of the users and will just leave. ['This page is unavailable' and so on ....].
Finally, you will see a blank page with a message coming up as soon as you right click the page. The message will be something like 'This page is no longer active'.
Example
<SCRIPT language=JavaScript>
<!-- http://www.spacegun.co.uk -->
var message = "**This page is no longer active**";
function rtclickcheck(keyp){ if (navigator.appName == "Netscape" && keyp.which == 3){ alert(message); return false; }
if (navigator.appVersion.indexOf("MSIE") != -1 && event.button == 2) { alert(message); return false; } }
document.onmousedown = rtclickcheck;
</SCRIPT>
I do know that one can remove the <html hidden> or the Javascript script with some add-ons such as Firebug but anyway you will need to decrypt the code with a password in order to see the real page.
Expert users might view the source code with a Brute Force attack, I think.
So, nothing is safe.
I found out an application that you need to instal on your computer.
There is a feature in the Enterprise version but you must pay to get it. This feature is a tool which encrypt your HTML page creating an ultra-strong password encryption for HTML files using up to 384 bit keys for encryption [the link I wrote above uses up to 256 bit keys for encryption].
I have never tried it out, though, because it is not for free.
Anyway, the link of the software 'HTML Guardian' - http://www.protware.com/default.htm
For the feature about the encryption, merely click on 'Ultra-Strong HTML password protection' in the page.
You cannot hide the source code, but you can add some difficulties to see your source code by following way
1. Disable right-click:
<body oncontextmenu="return false">
2.Disable ctrl, u, F12 keys:
<script type="text/javascript">
function mousehandler(e) {
var myevent = (isNS) ? e : event;
var eventbutton = (isNS) ? myevent.which : myevent.button;
if ((eventbutton == 2) || (eventbutton == 3)) return false;
}
document.oncontextmenu = mischandler;
document.onmousedown = mousehandler;
document.onmouseup = mousehandler;
function disableCtrlKeyCombination(e) {
var forbiddenKeys = new Array("a", "s", "c", "x","u");
var key;
var isCtrl;
if (window.event) {
key = window.event.keyCode;
//IE
if (window.event.ctrlKey)
isCtrl = true;
else
isCtrl = false;
}
else {
key = e.which;
//firefox
if (e.ctrlKey)
isCtrl = true;
else
isCtrl = false;
}
if (isCtrl) {
for (i = 0; i < forbiddenKeys.length; i++) {
//case-insensitive comparation
if (forbiddenKeys[i].toLowerCase() == String.fromCharCode(key).toLowerCase()) {
return false;
}
}
}
return true;
}
</script>
3. Add to lots of white spaces to before you staring your codes
it may fool someone
There isn't really anyway to do it that would stop a someone who is sophisticated.
There isn't really a way to do that. Perhaps the only thing you could do is to disable the right click feature via JavaScript, but still that wouldn't stop a user who's experienced enough to copy it. However, check this out.
for php, separate the code you don't want seen from the rest of your code with:
<?php
for($i=0;$i<1000000;$i++){
echo "\n";
}
?>
<some html="what you want to hide">
<?php
for($i=0;$i<1000000;$i++){
echo "\n";
}
?>
This will effectively kill the view source aspect (at least for a few minutes)
if it is a viewing source, he will not wait for the results.
Also, this does not seem to slow the page load
I know, it's a little late, but I guess you are looking for something called obfuscation. For Javascript files for example are many obfuscation tools available that you can use for the build process of your webpage. The code is transferred in an unreadable format. Some VPS providers are offers plugins that run during the build process and do that job for you.
As many have said, there's no real way to hide source code. There's been some good suggestions but I haven't seen this. This will encode it so nobody can read it, and it will 100% work for HTML. Only thing is anyone smarter than a light bulb will be able to decode it the same way it was encoded. You also cannot encode JavaScript or PHP; HTML only. developers.evrsoft.com offers a free encoder. But again, it can be decoded as quickly as it was encoded.
It'll look like this:
<h1>This will be encoded</h1>
Will be:
<script>
<!--
document.write(unescape("%3Ch1%3EThis%20will%20be%20encoded%3C/h1%3E"));
//-->
</script>
Again, don't encode PHP or JS.

Correct way to use Modernizr to detect IE?

I wanted to use the Modernizr JS library to detect for some browser properties to determine what content to show or not show.
I have an app called Pano2VR which outputs both HTML5 and SWF. I need the HTML5 for iOS device users.
However, IE does not render this "HTML5" output at all. It seems their output uses CSS3 3D transforms and WebGL, one or more apparently unsupported in IE9.
So, for those users I need to display the Flash version. I was planning to use an IFRAME and either pass the SRC via a Modernizr script or document.write out the correct IFRAME code depending on browser.
All of which leads to how do I use Modernizr to detect simply IE or not IE? Or detect for CSS 3d transforms?
Or is there another way to do this?
Modernizr doesn't detect browsers as such, it detects which feature and capability are present and this is the whole jist of what it's trying to do.
You could try hooking in a simple detection script like this and then using it to make your choice. I've included Version Detection as well just in case that's needed. If you only want to check of any version of IE you could just look for the navigator.userAgent having a value of "MSIE".
var BrowserDetect = {
init: function () {
this.browser = this.searchString(this.dataBrowser) || "Other";
this.version = this.searchVersion(navigator.userAgent) || this.searchVersion(navigator.appVersion) || "Unknown";
},
searchString: function (data) {
for (var i = 0; i < data.length; i++) {
var dataString = data[i].string;
this.versionSearchString = data[i].subString;
if (dataString.indexOf(data[i].subString) !== -1) {
return data[i].identity;
}
}
},
searchVersion: function (dataString) {
var index = dataString.indexOf(this.versionSearchString);
if (index === -1) {
return;
}
var rv = dataString.indexOf("rv:");
if (this.versionSearchString === "Trident" && rv !== -1) {
return parseFloat(dataString.substring(rv + 3));
} else {
return parseFloat(dataString.substring(index + this.versionSearchString.length + 1));
}
},
dataBrowser: [
{string: navigator.userAgent, subString: "Edge", identity: "MS Edge"},
{string: navigator.userAgent, subString: "MSIE", identity: "Explorer"},
{string: navigator.userAgent, subString: "Trident", identity: "Explorer"},
{string: navigator.userAgent, subString: "Firefox", identity: "Firefox"},
{string: navigator.userAgent, subString: "Opera", identity: "Opera"},
{string: navigator.userAgent, subString: "OPR", identity: "Opera"},
{string: navigator.userAgent, subString: "Chrome", identity: "Chrome"},
{string: navigator.userAgent, subString: "Safari", identity: "Safari"}
]
};
BrowserDetect.init();
document.write("You are using <b>" + BrowserDetect.browser + "</b> with version <b>" + BrowserDetect.version + "</b>");
You can then simply check for:
BrowserDetect.browser == 'Explorer';
BrowserDetect.version <= 9;
You can use Modernizr to detect simply IE or not IE, by checking for SVG SMIL animation support.
If you've included SMIL feature detection in your Modernizr setup, you can use a simple CSS approach, and target the .no-smil class that Modernizr applies to the html element:
html.no-smil {
/* IE/Edge specific styles go here - hide HTML5 content and show Flash content */
}
Alternatively, you could use Modernizr with a simple JavaScript approach, like so:
if ( Modernizr.smil ) {
/* set HTML5 content */
} else {
/* set IE/Edge/Flash content */
}
Bear in mind, IE/Edge might someday support SMIL, but there are currently no plans to do so.
For reference, here's a link to the SMIL compatibility chart at caniuse.com.
Detecting CSS 3D transforms
Modernizr can detect CSS 3D transforms, yeah. The truthiness of Modernizr.csstransforms3d will tell you if the browser supports them.
The above link lets you select which tests to include in a Modernizr build, and the option you're looking for is available there.
Detecting IE specifically
Alternatively, as user356990 answered, you can use conditional comments if you're searching for IE and IE alone. Rather than creating a global variable, you can use HTML5 Boilerplate's <html> conditional comments trick to assign a class:
<!--[if lt IE 7]> <html class="no-js lt-ie9 lt-ie8 lt-ie7"> <![endif]-->
<!--[if IE 7]> <html class="no-js lt-ie9 lt-ie8"> <![endif]-->
<!--[if IE 8]> <html class="no-js lt-ie9"> <![endif]-->
<!--[if gt IE 8]><!--> <html class="no-js"> <!--<![endif]-->
If you already have jQuery initialised, you can just check with $('html').hasClass('lt-ie9'). If you need to check which IE version you're in so you can conditionally load either jQuery 1.x or 2.x, you can do something like this:
myChecks.ltIE9 = (function(){
var htmlElemClasses = document.querySelector('html').className.split(' ');
if (!htmlElemClasses){return false;}
for (var i = 0; i < htmlElemClasses.length; i += 1 ){
var klass = htmlElemClasses[i];
if (klass === 'lt-ie9'){
return true;
}
}
return false;
}());
N.B. IE conditional comments are only supported up to IE9 inclusive. From IE10 onwards, Microsoft encourages using feature detection rather than browser detection.
Whichever method you choose, you'd then test with
if ( myChecks.ltIE9 || Modernizr.csstransforms3d ){
// iframe or flash fallback
}
Don't take that || literally, of course.
If you're looking for a JS version (using a combination of feature detection and UA sniffing) of what html5 boilerplate used to do:
var IE = (!! window.ActiveXObject && +(/msie\s(\d+)/i.exec(navigator.userAgent)[1])) || NaN;
if (IE < 9) {
document.documentElement.className += ' lt-ie9' + ' ie' + IE;
}
Well, after doing more research on this topic I ended up using following solution for targeting IE 10+.
As IE10&11 are the only browsers which support the -ms-high-contrast media query, that is a good option without any JS:
#media screen and (-ms-high-contrast: active), screen and (-ms-high-contrast: none) {
/* IE10+ specific styles go here */
}
Works perfectly.
CSS tricks have a good solution to target IE 11:
http://css-tricks.com/ie-10-specific-styles/
The .NET and Trident/7.0 are unique to IE so can be used to detect IE version 11.
The code then adds the User Agent string to the html tag with the attribute 'data-useragent', so IE 11 can be targeted specifically...
I agree we should test for capabilities, but it's hard to find a simple answer to "what capabilities are supported by 'modern browsers' but not 'old browsers'?"
So I fired up a bunch of browsers and inspected Modernizer directly.
I added a few capabilities I definitely require, and then I added "inputtypes.color" because that seems to cover all the major browsers I care about: Chrome, Firefox, Opera, Edge...and NOT IE11. Now I can gently suggest the user would be better off with Chrome/Opera/Firefox/Edge.
This is what I use - you can edit the list of things to test for your particular case.
Returns false if any of the capabilities are missing.
/**
* Check browser capabilities.
*/
public CheckBrowser(): boolean
{
let tests = ["csstransforms3d", "canvas", "flexbox", "webgl", "inputtypes.color"];
// Lets see what each browser can do and compare...
//console.log("Modernizr", Modernizr);
for (let i = 0; i < tests.length; i++)
{
// if you don't test for nested properties then you can just use
// "if (!Modernizr[tests[i]])" instead
if (!ObjectUtils.GetProperty(Modernizr, tests[i]))
{
console.error("Browser Capability missing: " + tests[i]);
return false;
}
}
return true;
}
And here is that GetProperty method which is needed for "inputtypes.color".
/**
* Get a property value from the target object specified by name.
*
* The property name may be a nested property, e.g. "Contact.Address.Code".
*
* Returns undefined if a property is undefined (an existing property could be null).
* If the property exists and has the value undefined then good luck with that.
*/
public static GetProperty(target: any, propertyName: string): any
{
if (!(target && propertyName))
{
return undefined;
}
var o = target;
propertyName = propertyName.replace(/\[(\w+)\]/g, ".$1");
propertyName = propertyName.replace(/^\./, "");
var a = propertyName.split(".");
while (a.length)
{
var n = a.shift();
if (n in o)
{
o = o[n];
if (o == null)
{
return undefined;
}
}
else
{
return undefined;
}
}
return o;
}
I needed to detect IE vs most everything else and I didn't want to depend on the UA string. I found that using es6number with Modernizr did exactly what I wanted. I don't have much concern with this changing as I don't expect IE to ever support ES6 Number. So now I know the difference between any version of IE vs Edge/Chrome/Firefox/Opera/Safari.
More details here: http://caniuse.com/#feat=es6-number
Note that I'm not really concerned about Opera Mini false negatives. You might be.
You can use the < !-- [if IE] >
hack to set a global js variable that then gets tested in your normal js code. A bit ugly but has worked well for me.

multiple tinyMce instances not working in chrome

As with the title in Chrome (v.4.1) multiple tinyMce (v2.08) instances do not work. To be exact the first two instances are ok, the others not, and chrome gives this error:
Uncaught Error: INDEX_SIZE_ERR: DOM Exception 1
Has this happened before?
Unfortunately I can't show you any code because it's for an admin area, I just need some clue for the moment.
Yes, as user XP1 noted, at this link you can find resolution for a comprimed TinyMCE source:
http://my.opera.com/XP1/blog/2011/07/21/tinymce-javascript-error-in-opera-getrangeat-index-size-err
But if you want to work with original uncomprimed source (it's just a bit easier), here is the solution:
Look for code "setRng : function(r) {" (without quotes) and exchange the whole function with:
setRng : function(r) {
var s, t = this;
if (!t.tridentSel) {
s = t.getSel();
if (s) // this block fixed according to TinyMCE JavaScript error in Opera (getRangeAt, INDEX_SIZE_ERR); http://my.opera.com/XP1/blog/2011/07/21/tinymce-javascript-error-in-opera-getrangeat-index-size-err
{
if(s.anchorNode === null && s.focusNode === null)
{
t.explicitRange = r;
try {
s.removeAllRanges();
} catch (ex) {
// IE9 might throw errors here don't know why (NOW WE KNOW WHY DAMMIT!)
}
s.addRange(r);
}
if (s.rangeCount > 0)
t.selectedRange = s.getRangeAt(0);
}
} else {
// Is W3C Range
if (r.cloneRange) {
t.tridentSel.addRange(r);
return;
}
// Is IE specific range
try {
r.select();
} catch (ex) {
// Needed for some odd IE bug #1843306
}
}
},
ONE NOTE: please make sure variables match. I am not sure how it is between different TinyMCE versions BUT the variables are not the same between comprimed and src mutations of the script file.
Take Care and God Speed