How to make an "adult content warning" on a static website? [closed] - javascript

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 4 years ago.
Improve this question
How can a static website (for example one built using Hugo or Jekyll) implement an "adult content warning"?
Ideally it should remember the user so they don't have to answer the question every time.
I'm asking for a friend.

The standard way to do this is to use localStorage (MDN | spec) to save a flag indicating that the user has already seen and agreed to the warning. (A decade ago it might have been a cookie, but web storage has near universal support now.)
But note that if the site is for adult material, many visitors will be in private browsing mode, and their localStorage for the site will be deleted when the private browsing tab is closed. So it will be of limited use (to those visitors).

Related

Save draft after page reload without registration via js or php [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 2 years ago.
Improve this question
In my site, user can write a text. I want to make that, when the user reloads the page, the draft will appear. Without any registration.
I think, using ip as id is bad idea, because it can be library wifi network, for example, and as far as I understand, all connected devices would have the same ip.
What is the best way to unify client for that purposes?
You should use cookies if you want it to be saved for a long time
PHP:
setcookie('text_cookie', 'My text', time() + 3600);//To save for an hour
echo $_COOKIE['text_cookie'];//To show
use javascript keyevent and localstorage

How to execute a cmd command in browser with js [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 5 years ago.
Improve this question
As the title,not only in IE.
If js can not do this,is there other way to do this?
It's best to show a demo code.
This cannot be done with Javascript. Browsers are deliberately isolated from the host machine to prevent malicious behaviour. So the amount of access to local resources is extremely limited (eg. uploading a file) and can only be initiated by the user.
In the past, you could have used ActiveX controls or Java applets to perform these types of actions, but Oracle has discontinued its browser plugin for applets and ActiveX controls do not run on all browsers.

How often should AJAX reload specific content on the page? [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 7 years ago.
Improve this question
I'm constructing an app where users can insert their preferences in a table. It is possible to load an updated version of the table via AJAX. I would like to load these updated versions from time to time, so the users will see almost always the newest version of the table, without reloading the page by themself. My questions regarding that are:
How often should the browser of the user request via AJAX a new version of the table?
Is that a bad approach? Maybe users want to reload the page manually.
Thank you for any answer in advance. Let me know how I can improve my question.
You should probably do it anywhere between 5 and 15 seconds. It's not a bad approach, and you can add a "refresh" button for manual refreshing. If your server is shared or there's lots of traffic, you can increase the duration to 30 seconds.
Note: This answer is based on my experience with web apps and previously built applications and web sites. There are no set standards for this behaviour.

Detect user's OS and rearrange/style download links [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
I have a website for an application I've developed, which is compiled for a variety of operating systems. On the downloads page, I would like to have it arranged so that the download link for the user's OS is at the top with a big obvious "Download!" button, with the other options listed below in plainer links. How can I do this?
When you log window in Mozilla's developer console you can see all the properties of window, this is quite useful and fun to find new things.
When I did so there is a property called navigator, and within that platform.
So, since I was running Linux when I did this, the value of window.navigator.platform was equal to "Linux".
One easy way you could do this is:
document.getElementById("download_btn").setAttribute("href","downloads/package_" + window.navigator.platform + ".zip");
So, if I were to download it off your site, I would download the file "package_Linux.zip".
Type navigator in your javascript console and check out all the goodies you have access to. In particular, userAgent and platform.
Combine that with some regex matches and the help of user agent strings list and you're good to go.

That technology used in Soundcloud? [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
What technology used in Soundcloud that prevents stopping music when you press back button in browser?
I can't find anything about it.
Sorry for my english.
They use the History Api, which allows you to manipulate the Browsers history, without forcing a full page-reload.
It's pretty cool indeed. I think they load every page with ajax, and then handle the browser history themselves, through javascript. That way you can leave the audio player in the page and load all the rest, achieving the non-stop-music effect

Categories

Resources