I tested a site for accessibility and I now have a QA validating that all of the changes were made. The QA needs to validate that the site is still readable with the stylesheets turned off. The QA can only use MS Edge and cannot install any plugins or browser extensions. Has anyone figured out how to turn off stylesheets? Googling this got me nowhere. When I evaluate the site, I use an extension in Chrome so I have never had this issue before.
Press F12 and copy this to console, hit enter
$('style,link[rel="stylesheet"]').remove()
Vanilla JS approach.
( [].slice.call( document.styleSheets ) ).map( function ( style ) {
var node = style.ownerNode;
node.parentNode.removeChild( node );
} );
ES6 Vanilla JS Version
[ ...document.styleSheets ].map( ( style ) => {
const node = style.ownerNode;
node.parentNode.removeChild( node );
} );
Related
I've recently put a new style live on: summerboardingcourses.co.uk
I've had report from one user that they are seeing the old website (with broken styles) on iPhone Safari browser from Poland (I am based in the UK). I can't replicate the issue, every VPN I use, or GeoLocation Screenshot tool I've used (e.g. localbrowser.com) the site is viewing correctly.
Has anyone ever had an issue like this before? I can't understand why they would be seeing the old site.
Any advice at all would be fantastic.
Thanks,
Meg
/* Return Last modified date or current date*/
function get_mod_time($file) {
if (file_exists($file)) {
return date("y.m.d-H", filemtime($file));
}
else {
return date('y.m.d-H');
}
}
/* Include style */
$css_file = get_template_directory_uri() . '/assets/css/style.css';
wp_enqueue_style( 'site-css', $css_file, array(), get_mod_time($css_file), 'all' );
Same think you can do for your custom JS files, you get last modified date as version name, that forces clear cache if file on server updated
Is there a way to get a list of the custom CSS changes you applied within the Chrome dev tools?
When you're playing with CSS in the Chrome dev tools to get your web page look right, it would come in handy to easily track the changes you made.
I know about workspaces, but the use case is an Angular 5 app where your CSS is bundled and possibly minified.
To clarify:
I have a page that is looking pretty far from what it should look like
I do 20 CSS fixes in dev tools until it looks good
now I want to get a (CSS) delta from the original page so I have a list of changes I should now implement in the real CSS styles.
You can see all changes via the Changes Drawer
In Dev Tools, you can locate the Changes Drawer via either:
A) Open Command Palette (Ctrl + Shift + P) and type "changes"
B) Open Drawer (Esc), click on the more options menu (triple dot), and select Changes
Further Reading
How to get a summary of your CSS changes in Chrome dev tools?
Export CSS changes from inspector (webkit, firebug, etc)
Updates
Dev Tools 98 added More precise changes to automatically pretty prints changes
Issue #1296143 opened User-Select: none in Changes drawer makes it very hard to utilize
Actually you could do exactly what you want:
Go to Sources > > Local Modifications
Going to the Sources tab, choosing your desired CSS file, and then right click and choose Local modifications will give you a diff style summary of your local changes.
Or - you could just save the changes directly to a local CSS file by mapping that local file so that chrome dev tools will automatically save any change that you made to this CSS file.
That depends on how you apply css fixes.
If you apply css code inline,you can't get a file with list of fixes you made.
If you made your changes in inspector-stylesheet you can find that file with all your fixes
Go to Source tab > from the left list open localhost > you can
see file called inspector-stylesheet.
Which will show all your fixes.
Another way to pick your css fixes from 'Elements' tab in dev tool you can easy copy edits you made and paste it in your css file of your project or you can edit source file itself from 'Source' tab in dev tool you have two things to do to keep what changes you made:
By pressing Ctrl + S or Cmd + S to save changes and automatically will save changes in your root css file in your project files.
You can copy and paste changes from dev tool to your css file in your code editor
Well, I learned something new 😯
How to monitor changes to inline styles in console
https://developer.mozilla.org/en-US/docs/Web/API/MutationObserver
references: https://hacks.mozilla.org/2012/05/dom-mutationobserver-reacting-to-dom-changes-without-killing-browser-performance/
const targetNode = document
// Options for the observer (which mutations to observe)
const config = { attributes: true, childList: true, subtree: true };
// Callback function to execute when mutations are observed
const callback = function(mutationsList, observer) {
// Use traditional 'for loops' for IE 11
for(let mutation of mutationsList) {
if (mutation.type === 'childList') {
console.log('A child node has been added or removed.');
}
else if (mutation.type === 'attributes') {
console.log('The ' + mutation.attributeName + ' attribute was modified.');
console.log({
mutation,
inline: mutation.target.style[0],
style: mutation.target.style[mutation.target.style[0]]
})
}
}
};
// Create an observer instance linked to the callback function
const observer = new MutationObserver(callback);
// Start observing the target node for configured mutations
observer.observe(targetNode, config);
This does not solve the problem
but could be used as a starting point for a custom solution to the problem.
custom diffing of each element replacing old values with the latest values you could end up with a diff of all changes up to this point using your own maintained list.
This could be a pr to each of the browsers or created as a chrome extension. Goodluck, wanted to present a possible solution instead of saying it was impossible.
I know it's "another" subject, but you can try to launch it in some live checker extension in VS Code in order to follow everything...
Before 3.2, I can set the menu item type to "external link" and then set the link as
"javascript:myFunction()"
When clicked, the menu item will call the JavaScript function. But after I upgraded to 3.2, when I did the same thing and tried to save the menu item, it said "Save not permitted".
Did 3.2 block this usage? If yes, how do I get my JS function executed by a menu item?
I've came up this problem a while ago, in Joomla version 3.2.1 concerning a 'Skype' link, e.g.
skype:myloginname
This has to do with the protocol types that are allowed and are defined in this file:
/administrator/components/com_menus/controllers/item.php, line ~180.
There is an array that defines the acceptable schemes:
$scheme = array('http', 'https', 'ftp', 'ftps', 'gopher', 'mailto', 'news', 'prospero', 'telnet', 'rlogin', 'tn3270', 'wais', 'url', 'mid', 'cid', 'nntp', 'tel', 'urn', 'ldap', 'file', 'fax', 'modem', 'git');
When adding skype at the end of the list Joomla! allowed saving the external link. The same applies for javascript. In any case you should consider any security risk that comeswith this solution.
In addition, you should take into mind that this override may be discarded in any future update of joomla.
Technically speaking Joomla thinks that javascript is a protocol, like HTTP & Co., it looks it up inside a list of known protocols, it does not find it and it throws an error.
Start reading at around line inside [MenusControllerItem::save()][1]. So basically it has nothing to do with the fact you are trying to use some JavaScript, this is just a side-effect.
While using JavaScript in the External Link is not really an advertised feature but rather said a loophole, it does break b/c if you have used before.
You can:
Open an issue in the Joomla Issue Tracker and report this issue, get some community feedback. The fix is really easy, it just needs to get accepted.
Use the suggestion below:
Instead of link put #
Set the field "Link CSS Style" to something that does not colide with other classes, eg. my-function
Save
You can use jQuery to intercept the click event on the link and to make it run your function. See code below:
jQuery(document).ready(function($){
// Select element based on the class set in Joomla backend
$( ".my-function" ).on( "click", function(e) {
// Do not follow the link
e.preventDefault();
// Call function
myFunction(1);
});
});
function myFunction(x)
{
alert("I was called" + x);
}
Update: after a short discussion with the commiter of the change, I understood that it may be related to a security issue. So it may be on purpose after all not to allow js.
I'd like to change a link's href based on that: if Skype isn't installed, show a popup explaining what Skype is and how to install it, if it is installed, change the link to skype:my.contact.name?call so the click will start a call. Real estate issues means that I'd prefer to only have one link shown.
Unfortunately, browsers do not support such API and this cannot be done cross-browser compatible way. There is some kind of support, but it is buggy.
Javascript to detect Skype?
All browser plugins registering their mime-types in global array named mimeTypes, that can be accessed via navigator object navigator.mimeTypes.
So you can use this for check plugin active or not. If plugin installed and disabled — no any mime-type will be registred for that disabled plugin. If plugin installed and active — he has a mime-type record in navigator.mimeTypes
Some code implementation using jQuery:
jQuery.extend({checkPlugin: function(mimetype_substr) {
for (var i = 0; i < navigator.mimeTypes.length; i++) {
if (navigator.mimeTypes[i]['type'].toLowerCase().indexOf(mimetype_substr) >= 0) {
console.log("Gotcha! Here it is: "+navigator.mimeTypes[i]['type']);
return true;
}
}
return false;
}});
So this: $.checkPlugin("skype"); returns true if skype click2call plugin is installed and active. And false if there is no active plugin or plugin are not installed.
Actually need to search within another global array — navigator.plugins, but all active plugins have their records in navigator.mimeTypes, and this is a bit easier.
I've recently built and launched this page: http://www.thaiestatenetwork.com
It works great in Chrome, Safari, Firefox and even IE10, but in IE8 and 9 all I get is a blank page.
I've read through post here on SO about similar issues and based on that I've tried this:
going over my templates in an attempt to find DOM errors.
Tried setting position:static on html and body
commented out #font-face in my CSS (since I was getting an error in IE on BrowserStack related to #font-face)
Checked for potential CORS issues. Found none.
None of it works.
Strangely too, when I tunnel to my local dev machine through BrowserStack, everything works like a charm.
I should add that the site is built using router https://github.com/tmeasday/meteor-router and runs on Heroku using this build pack: https://github.com/oortcloud/heroku-buildpack-meteorite
I really hope someone out there has that fresh pair of eyes that will lead me on the right track.
I've solved it!
The issue turned out to be related to the way I was initializing Google Analytics (GA). I was doing this:
Template.menu.created = function() {
// GA initialization code here
};
I had to do this:
Template.menu.rendered = function() {
if ( typeof ga === 'undefined' ) {
// GA initialization code here
}
};
So basically I was attempting to initialise GA on first creation of my menu template, but instead I had to latch on to the rendered callback and add a conditional to make sure I only initialise GA once.
Overall I am not thrilled with my approach to initialising GA, but that is another matter entirely. It works.