Demo: "Powerpoint-ify" a page.
See button above.
Display/hide parts of a page (div's) one by one.
This is done using my file
View HTML source and JS source for usage.
Note it does key handling (arrow keys) using document.onkeydown
and Key codes.
Exercise - Get "Powerpoint-ify" working on your site
- You need a long page on your site.
I suggest: Copy the module home page to your site.
- Examine the HTML of this page and copy in the section you need.
- Set up div's on the page and number them.
- Test it works.
Exercise - Write a more flexible "Powerpoint-ify"
- Don't have to number the div's. Just mark them:
- Don't need MAX.
- JS finds all div's of that class using:
var a = document.getElementsByClassName("pp"); // array
for ( var i = 0; i < a.length; i++ )
// if i is current page then show a[i]
// else hide a[i]
- How to block (or redirect) a link to me from a certain site:
var referrer = document.referrer;
var badstring = "BADSITE.COM";
if ( referrer.indexOf(badstring) != -1 )
window.location = "http://mysite.com/badsite.redirect.html";
Re-write the above with
Test it on your own site, with one page linking to another.
- Hide mailto: link from spambots.
s1 = "<a href=mail";
s1 = s1 + "to:user";
s1 = s1 + "id@dc";
s2 = "u.ie>email me</a>";
document.write ( s1 + s2 );
Q. What does spambot need to extract this address?
- How to stop another site enclosing me in a
if (top != self)
top.location.href = self.location.href;
It used to be that many big sites (like Google Images)
would frame you.
But not any more.
is for sharing pages on social media.
the pages that are shared.
A search for
Linkis links to tcd.ie
the page above
View source and you see it uses iframe to frame
this tcd.ie page
It adds extra bits to the page, even on top of the original page.
It also hides the original page's URL.
- If you don't like this, use a "Framekiller" as above.
share my site
using Linkis, the Linkis page starts to load and then it jumps out of the frame.
Move CPU load onto client
without burdening the server.
Good (for both client and server) to move CPU load onto client. Why?
If we label elements of a page,
in Event attributes.
<input id="thebutton" name="thebutton" type="button" value="Click to run function" />
document.getElementById('thebutton').onclick = fn;
If interpreted code is run millions of times, maybe it should be "compiled" to be as efficient as possible.
- Strip spaces, comments, do various transforms to reduce size - to make transmission faster
and parsing faster.
At expense of readability.
- Google does this for performance. ("View source" on Google pages.)
- See Google's
- Deliberately make it hard to read to protect intellectual property.
- Making obfuscated code may make larger, less efficient code.
Can be at odds with the performance goal of minification.
- Minified code looks fairly obfuscated anyway.
You cannot trust that they have other client-side technologies.
There are schemes where you can write in other languages
- Source-to-source compiler
- One analogy
- Another analogy
- WebAssembly (wasm).
A plan for a true assembly language for the Web.
Write in any language, compile to wasm.
But what if client-side can't support it?
Their plan is to detect that and have