pdfjs not opening links in separate window using LinkTarget.BLANK? - drupal

Can't get PDFjs to open links in a separate window, tried inserting
PDFJS.externalLinkTarget = PDFJS.LinkTarget.BLANK;
/sites/all/libraries/pdf.js/build/pdf.js
but after having cleared the cache they still open in the same window.
even tried commenting out
PDFJS.openExternalLinksInNewWindow = (
PDFJS.openExternalLinksInNewWindow === undefined ?
false : PDFJS.openExternalLinksInNewWindow);
FYI: Using this in Opigno LMS where a Slide renders the PDF with pdfjs.

After I upgraded from pdf 7.x-1.9 to the current 7.x-1.x-dev version with drush and cleared the cache it is working now, even when I reverted back the code so perhaps it's part of the new dev version :)

Related

Clicking on links in PDF in JxBrowser results in errors

I am using JxBrowser 6.14.2 in a Java Swing application and I'm encountering an issue when loading a PDF and attempting to load content for any links in the PDF document.
It seems to be related to the tab handling code in the Chrome PDF extension and it happens when using the JxBrowser default PopupHandler as well as a custom one.
Get the following error when the PDF is loaded:
[0104/095806:INFO:CONSOLE(0)] "Unchecked runtime.lastError while running tabs.get: No tab with id: 5.
at promises.push.Promise.then.streamInfo.tabUrl (chrome-extension://mhjfbmdgcfjbbpaeojofohoefgiehjai/browser_api.js:159:21)
at chrome-extension://mhjfbmdgcfjbbpaeojofohoefgiehjai/browser_api.js:158:21", source: chrome-extension://mhjfbmdgcfjbbpaeojofohoefgiehjai/index.html (0)
Then, when clicking any URL or mailto link, the following error occurs:
[0104/095952:INFO:CONSOLE(0)] "Unchecked runtime.lastError while running tabs.update: No current window
at NavigatorDelegate.navigateInCurrentTab (chrome-extension://mhjfbmdgcfjbbpaeojofohoefgiehjai/navigator.js:42:19)
at Navigator.onViewportReceived_ (chrome-extension://mhjfbmdgcfjbbpaeojofohoefgiehjai/navigator.js:169:31)
at OpenPDFParamsParser.getViewportFromUrlParams (chrome-extension://mhjfbmdgcfjbbpaeojofohoefgiehjai/open_pdf_params_parser.js:131:7)
at Navigator.navigate (chrome-extension://mhjfbmdgcfjbbpaeojofohoefgiehjai/navigator.js:125:28)
at PDFViewer.handlePluginMessage_ (chrome-extension://mhjfbmdgcfjbbpaeojofohoefgiehjai/pdf.js:614:27)", source: chrome-extension://mhjfbmdgcfjbbpaeojofohoefgiehjai/index.html (0)
The same errors even occur if a popup handler that "disables" popups is installed:
browser.setPopupHandler(p -> {
browser.loadURL(p.getURL());
return null;
});
Any ideas on how I might resolve this issue so that links in PDF documents behave as expected?
My name is Dmitry and Iā€™m on the JxBrowser Support team.
Thank you for reporting that issue.
Currently, links from PDF do not work in JxBrowser. I have created an appropriate task in our issue tracking system and we will fix it in one of the future versions of JxBrowser.

Having some issues with 2sxc version 9.x: unable to select App/Content layout

I have upgraded to v. 9.1.3 and I still have the same issue that I found with previous 9.x versions, so I'm still forced to use v.8.12 .
The problem is that I am unable to select the layout of any App/Content when I insert it to the page, after inserting I only see this button:
and when I click on it , nothing happen , and two errors appear in the console:
note1: the same error happen when I install 2sxc v.9.1.3 (or any older 9.x) on new and clean DNN v.9.1 website.
note2: the same error happen when I click on the layout button (the one with glasses icon) on previously installed app from the previous 8.12 version.
I fixed this by changing 'localhost' to be 'xlocalhost' in the var:
var
path = window.location.pathname,
isDevMode = window.location.hostname === 'localhost',
apiUrl;
in the file: DesktopModules\ToSIC_SexyContent\dist\ng\ui.html
For more info, see: $2sxc is not defined

Open PDF in the PhoneGap App that is made in HTML and CSS

I have a strange problem with my iPad App in Phone Gap. The problem is that I have to open PDF document in my app through links and when I click the link which opens the PDF, it shows me the PDF document with no back link.
Hence, when I open the PDF document in my app through a link, it takes me to a dead end and there is no way I can go back to the main page of my app.
My question is that how can I have a Top-Bar, when I open a PDF which could take me back to my home page? Any internal element for the iPad may be?
Thanks a lot.
Try using the In App Browser plugin.
If you're using a later Phonegap / Cordova version (2.8.0, 2.9.0 etc) it should come with it - nothing else to install.
http://docs.phonegap.com/en/2.9.0/cordova_inappbrowser_inappbrowser.md.html#InAppBrowser
It will allow you to open the PDF in the a new 'window' that overlays your app. It has a 'Done' button that users can use to close it and return to your app when they are finished.
You would open the PDF using the In-App Browser, using something like this:
window.open('http://whitelisted-url.com/pdftoopen.pdf', '_blank');
I.e. the _blank option triggers the In-App Browser plugin. If you were to use _system instead it might open it in iBooks (just guessing there - not 100% sure if it would use iBooks).
Try prefixing https://docs.google.com/viewer?url= in the URL
like, window.open('https://docs.google.com/viewer?url=http://www.example.com/example.pdf&embedded=true', '_blank', 'location=yes');
Try this to open any kind of documents from URL using following steps:
install this plugin : cordova plugin add https://github.com/ti8m/DocumentHandler
use this code :
handleDocumentWithURL(function() { console.log('success'); }, function(error) { console.log('failure'); if (error == 53) { console.log('No app that handles this file type.'); } }, 'http://www.example.com/path/to/document.pdf');
It works for me both on Android and IOS. I used it for open images and PDF files.
Android : It opens files using system apps if available, otherwise it give an error, which you can handle.
IOS : It opens files in popup like view with Done button and Option button.
It doesn't show your docs URL.
Source is available here : https://github.com/ti8m/DocumentHandler
Thanks asgeo1,
I solved it by using window.open().
<img src="images/samplens.jpg" border="0" />
Hope it helps.
I've ended up using WebIntent
as described here. The tricky part was to modify WebIntent.java to properly identify file type:
String type = obj.has("type") ? obj.getString("type") : null;
// New code starts
Uri uri = obj.has("url") ? Uri.parse(obj.getString("url")) : null;
String extension = MimeTypeMap.getFileExtensionFromUrl(obj.getString("url"));
if(extension != null){
MimeTypeMap mimeTypeMap = MimeTypeMap.getSingleton();
type = mimeTypeMap.getMimeTypeFromExtension(extension);
}
// New code ends
JSONObject extras = obj.has("extras") ? obj.getJSONObject("extras") : null;

How to force Chrome browser to reload .css file while debugging in Visual Studio?

I'm currently editing a .css file inside of Visual Studio 2012 (in debug mode). I'm using Chrome as my browser. When I make changes to my application's .css file inside of Visual Studio and save, refreshing the page will not load with the updated change in my .css file. I think the .css file is still cached.
I have tried:
CTRL / F5
In Visual Studio 2012,
Go to project properties, Web tab
Choose Start External Program in the Start Action section
Paste or browse to the path for Google Chrome (Mine is C:\Users\xxx\AppData\Local\Google\Chrome\Application\chrome.exe)
In the Command line arguments box put -incognito
Used the Chrome developer tools, click on the "gear" icon, checked "Disable Cache."
Nothing seems to work unless I manually stop debugging, (close out of Chrome), restart the application (in debug).
Is there any way to force Chrome to always reload all css changes and reload the .css file?
Update:
1. In-line style changes in my .aspx file are picked up when I refresh. But changes in a .css file does not.
2. It is an ASP.NET MVC4 app so I click on a hyperlink, which does a GET. Doing that, I don't see a new request for the stylesheet. But clicking F5, the .css file is reloaded and the Status code (on the network tab) is 200.
To force chrome to reaload css and js:
Windows option 1: CTRL + SHIFT + R
Windows option 2: SHIFT + F5
OS X: āŒ˜ + SHIFT + R
Updated as stated by #PaulSlocum in the comments (and many confirmed)
Original answer:
Chrome changed behavior. Ctrl + R will do it.
On OS X: āŒ˜ + R
If you have problems reloading css/js files, open the inspector
(CTRL + SHIFT + C) before
doing the reload.
There are much more complicated solutions, but a very easy, simple one is just to add a random query string to your CSS include.
Such as src="/css/styles.css?v={random number/string}"
If you're using php or another server-side language, you can do this automatically with time(). So it would be styles.css?v=<?=time();?>
This way, the query string will be new every single time. Like I said, there are much more complicated solutions that are more dynamic, but in testing purposes this method is top (IMO).
[READ THE UPDATE BELOW]
Easiest way I've found is in Chrome DevTools settings.
Click on the gear icon (or 3 vertical dots, in more recent versions) in the top-right of DevTools to open the "Settings" dialog.
In there, tick the box: "Disable cache (while DevTools is open)"
UPDATE: Now this setting has been moved. It can be found in the "Network" tab, it's a checkbox labeled "Disable Cache".
You are dealing with the problem of browser cache.
Disable the cache in the page itself. That will not save supporting file of page in browser/cache.
<meta http-equiv="cache-control" content="max-age=0" />
<meta http-equiv="cache-control" content="no-cache" />
<meta http-equiv="expires" content="0" />
<meta http-equiv="expires" content="Tue, 01 Jan 1990 12:00:00 GMT" />
This code you require/need to insert in head tag of the page you are debugging, or in head tag of master page of your site
This will not allow browser to cache file, eventually files will not be stored in browser temporary files, so no cache, so no reloading will be required :)
I am sure this will do :)
In my case,in Chrome DevTools settings, just set "Disable cache (while DevTools is open)" doesn't work, it needs to check "Enable CSS source maps" and "Auto-reload generated CSS",which are listed in source group, to make this cache issue go away.
i had faced same problem here! but I sure,my resolution is better than all above examples,just do this,
Pull up the Chrome developer console by pressing F12
Right click on the reload button at the top of the browser and select "Empty Cache and Hard Reload."
That`s it!
Press SHIFT+F5.
It is working for me with Chrome version 54.
With macOS I can force Chrome to reload the CSS file in by doing
āŒ˜ + SHIFT + R
Found this answer buried in the comments here but it deserved more exposure.
I'm using Edge Version 81.0.416.64 (Official build) (64-bit) and its based on the Chromium open source project.
Press F12 to get into Dev Tools.
Click Network Tab
Check Disable cache
Current version of Chrome (55.x) does not reload all resources when you reload the page (Command + R) - and that is not useful for debugging the .css file.
Command + R works fine if you want to debug only the .html, .php, .etc files, and is faster because works with local/cached resources (.css, .js).
To manually delete browser's cache for each debug iteration is not convenient.
Procedure to force reload .css file on Mac (Keyboard Shortcut / Chrome):
Command + Shift + R
I know it's an old question, but if anyone is still looking how to reload just a single external css/js file, the easiest way now in Chrome is:
Go to Network tab in DevTools
Right click on the resource and select Replay XHR to repeat the request
Make sure that the Disable cache option is selected to force the reload.
For macOS Chrome:
Open developers tools cmd+alt+i
Click three dots on the top right corner in developers tools
Click settings
Scroll down to Network
Enable Disable cache (while DevTools is open) see screenshot:
Why is it needed to refresh the whole page? Just refresh only css files without reloading the page. It is very helpful when, for example, you have to wait a long response from DB. Once you get data from DB and populate the page, then edit your css files and reload them in Chrome (or in Firefox). To do that you need to install CSS Reloader extension. Firefox version is also available.
You can copy paste this script into Chrome console and it forces your CSS scripts to reload every 3 seconds. Sometimes I find it useful when I'm improving CSS styles.
var nodes = document.querySelectorAll('link');
[].forEach.call(nodes, function (node) {
node.href += '?___ref=0';
});
var i = 0;
setInterval(function () {
i++;
[].forEach.call(nodes, function (node) {
node.href = node.href.replace(/\?\_\_\_ref=[0-9]+/, '?___ref=' + i);
});
console.log('refreshed: ' + i);
},3000);
I solved by this simple trick.
<script type="text/javascript">
var style = 'assets/css/style.css?'+Math.random();;
</script>
<script type="text/javascript">
document.write('<link href="'+style+'" rel="stylesheet">');
</script>
Still an issue.
Using parameters like "..css?something=random-value" changes nothing in my customer-support experience. Only name changes works.
Another take on the file renaming. I use URL Rewrite in IIS. Sometimes Helicon's Isapi Rewrite.
Add new rule.
+ Name: lame-chrome-fix.
+ Pattern: styles/(\w+)_(\d+)
+ Rewrite URL: /{R:1}.css
Note: I reserve the use of undercase to separate the name from the random number. Could be anything else.
Example:
<link href="/styles/template_<%
Response.Write( System.DateTime.UtcNow.ToString("ddmmyyhhmmss")); %>"
type="text/css" />
(No styles folder it's just a name part of the pattern)
Output code as:
<link href="/styles/template_285316115328"
rel="stylesheet" type="text/css">
Redirect as:
(R:1 = template)
/template.css
Only the explanation is long.
Hold down Ctrl and click the Reload button. Or, Hold down Ctrl and press F5. just open the Chrome Dev Tools by pressing F12. Once the chrome dev tools are open, just right click on the refresh button and a menu will drop down.
Just had this problem where one person running Chrome (on a Mac) suddenly stopped loading the CSS file. CMD + R did NOT work at all. I don't like the suggestions above that force a permanent reload on the production system.
What worked was changing the name of the CSS file in the HTML file (and renaming the CSS file of course). This forced Chrome to go get the latest CSS file.
If you are using Sublime Text 3, using a build system to open the file opens the most current version and provides a convenient way to load it via [CTRL + B]
To set up a build system that opens the file in chrome:
Go to 'Tools'
Hover your mouse over 'build system'. At the bottom of the list brought up, click 'New Build System...'
In the new build system file type this:
{"cmd": [ "C:\\Program Files (x86)\\Google\\Chrome\\Application\\chrome.exe", "$file"]}
**provided the path stated above in the first set of quotes is the path to where chrome is located on your computer, if it isn't simply find the location of chrome and replace the path in the first set of quotes with the path to chrome on your computer.
The most simplest way to achieve your goal is to open a new incognito window in your chrome or private window in firefox which will by default, not cache.
You can use this for development purposes so that you don't have to inject some random cache preventing code in your project.
If you are using IE then may god help you!
Ctrl + F5
Shift + F5
Both work
Easiest way on Safari 11.0 macOS SIERRA 10.12.6:
Reload Page From Origin, you can use help to find out where in the menu it is located, or you can use the shortcut option(alt) + command + R.
One option would be to add your working directory to your Chrome "workspace" which allows Chrome to map local files to those on the page. It will then detect changes in the local files, and update the page in real-time.
This can be done from the "Sources" tab of Devtools:
Click on the "Filesystem" tab in the file browser sidebar, then click the +Plus sign button to "Add folder to workspace" - you will be prompted with a banner at the top of the screen to allow or deny local file access:
Once allowed, the folder will appear in the "Filesystem" tab on the left. Chrome will now attempt to associate each file in the filesystem tab with a file in the page. Sometimes you will need to reload the page once for this to function correctly.
Once this is done, Chrome should have no trouble picking up local changes, in fact you won't even need to reload to get the changes in many cases, and you can make edits to the local files directly from Devtools (which is extremely useful for CSS, it even comments out CSS lines when you toggle the checkboxes in the Styles tab).
More information on Workspaces in Chrome.
Chrome/firefox/safari/IE will reload the entire page by these shortcuts
Ctrl + R (OR) Ctrl + F5
Hope it may helps you!.
If you are using SiteGround as your hosting company and none of the other solutions have worked, try this:
From the cPanel, go to "SITE IMPROVEMENT TOOLS" and click "SuperCacher." On the following page, click the "Flush Cache" button.

Drop-down menu of Dojo do not open up in QtWeb browser

I am using QtWeb browser (www.qtweb.net) for my development. When I try to open the following URL in the browser, the drop-down menus of the buttons do not open up:
http://archive.dojotoolkit.org/nightly/dojotoolkit/dijit/tests/form/test_Button.html
This issue is not seen across other browsers.
Any workarounds/suggestions/ideas would be appreciated.
I encountered the same problem. Interestingly, the popup menus do not work since version 1.7.1.
This is not bug of dojo. This is some mistake in QtWebKit. The problem in touchpad device that defined by default in precomiled qt webkit libs (even if the touchpad does not exists physically).
Temporary solution is to edit dojo/has.js file (find this lines in dojo >= 1.7.1):
if(has("host-browser")){
var agent = navigator.userAgent;
has.add("dom-addeventlistener", !!document.addEventListener);
has.add("touch", "ontouchstart" in document); <<<<< Comment this line
has.add("device-width", screen.availWidth || innerWidth);
has.add("agent-ios", !!agent.match(/iPhone|iP[ao]d/));
has.add("agent-android", agent.indexOf("android") > 1);
}
Here another solution (more painfully):
Link to the helpful message source
You must recompile QtWebKit with DEFINES+=ENABLE_TOUCH_EVENTS=0 that defined in WebCore/features.pri.
Then you qt web projects will be work properly!

Resources