I know it sounds weird, but i need to make that…
So I have this function, that activates onClick.
function opensite() { location.href='https://www.site.com/'; }
Is there a way to open that url, but not load it?
So your browser will say something like "page not found/server down/no internet connection"…
Is it possible and how ? My server can use every language … (JS,JQUERY,PHP,HTML…)
Why I should do this ? Long story, please don't ask about ;)
Thank you
Evert
*EDIT*
I have a script that perfectly works without internet connection because it doesn't load the page in the 'link'… I'm trying to make this also work WITH internet connection...
Are you looking for this?
window.open('http://www.site.com/')
But some browser will block the pop-up window. There's also another way:
var a = document.createElement('a');
a.href = 'http://www.site.com/';
a.target = '_blank';
a.click();
to emulate a click on a link.
If you own the site you are trying to make appear offline, then the easiest way is to upload an index.html containing the error you are trying to display.
But really, no. This is not possible.
I am assuming you do not own the other site, and due to security reasons, browsers block this type of behavior. Since you are asking to bypass security settings, and telling us "don't ask" I can only assume you are trying to steal peoples identities.
No matter how bad you need this to work, it wont. Stop trying.
Edit:
If you simply do not want your website to follow a click, then I would use e.preventDefault() in your jQuery event handler
Related
so i know this may sound stupid, but I want to know if there is any way that i could redirect someone to a website, and then display an alert box on the web page, using either javascript or any other interface that can be weaved into HTML5. I asked some of my classmates, and they didn't know, so I just need a confirmation that this isn't possible.
I have ran a few trials i found, but on further review, they wouldn't work.
edit I have control over the site, but I wish for the box to only pop up if i redirect it.
I can give the code if it would help, but I'm doubtful it will help
sorry for wasting your time if i did. thanks.
Similar to Gerard's answer, but using query strings. A possibly more standard solution.
On the first page:
<script>
window.location = 'https://{your website here}/?showAlert=true';
</script>
Then on the 2nd page.
const urlParams = new URLSearchParams(window.location.search);
const showAlert = urlParams.get('showAlert');
if(showAlert === "true") {
alert("Hello");
}
Note this will not work in internet explorer
You could communicate to the new site that it's a redirect by appending the route:
On the site you want to redirect from:
<script>
// if you can't use a normal link, change the url with JS
window.location = 'https://{your website here}/#redirect';
</script>
On the site you want to show the alert:
<script>
if (window.location.pathname.includes('#redirect') alert('What you want to say');
</script>
If you only have control over the first site, you could alert before redirecting, there wouldn't be much difference to the user since the alert blocks execution of other code.
You can call an alert box in a HTML document with JavaScript like this:
window.onload = function () {
alert("Hello World!");
}
-> https://jsfiddle.net/u8x6s31v/
You can also redirect somebody, if the page he's visiting is yours. Is that what you mean?
Update:
I think you can't see the URL where someone comes from with JavaScript. The only way to trigger scripts for some people is to add a hash.
window.onload = function () {
hashUrl = window.location.hash;
if (hashUrl == "#alert") {
alert("Hello World!");
}
}
Then call for example: domain.tld/path/index.html#alert
-> https://jsfiddle.net/u8x6s31v/1/
This is a vague questions with a lot of possible answers but seeing as how you're new, I'm going to speculate on what you might be asking and try to answer it.
It's not clear what you mean by "redirect".
Is this a server-side redirect like when you move/change a URL and you redirect the old URL to a new URL? Is this a Javascript meta refresh that you put in a 404 template? Is this a redirect that occurs after a user takes an action?
Regardless, you're going to have to "annotate" that user and then take action upon that annotation. The most obvious method would be based on the "referrer" HTTP header but it is also possible to do it based on the presence of a cookie.
Additionally, adding URL parameters to a redirect is trivially easy and often used for stuff like this.
The immediate things that come to my mind would be via Google Analytics (preferably implemented via Google Tag Manager because it'll make it easier).
Look into "outbound link tracking", "cross-domain tracking" and "UTM campaign tracking" (all related to Google Analytics and/or Google Tag Manager) and you'll probably find something that suits your needs.
URL shorteners are commonly used to mask parameters in links and there are open source libraries that allow you to host your own URL shortener (which you could integrate into your redirects) or do some other type of link tracking like is often used for affiliates.
I want to secure JavaScript Codes. I secure my JavaScript with https://javascriptobfuscator.com/ but it can also stolen from view source.
I want a codes which redirect to my website when JavaScript used on wrong site.
This is possible I know but I don't know how?
What you could do is check the return of location.host or location.hostname.
To redirect to another URL you would change the value of location:
location = "https://mywebsite.com";
//or alternatively
location.assign("https://mywebsite.com");
However, the redirection may will be prevented by Cross-origin resource sharing policies (see Michael's comment). So you could just display an alert dialog.
alert("Don't use my script on your website");
The person trying to use your code on their website will be warned during development by this alert.
In any case, your obfuscated code can still be changed and someone that is determined will remove these "security" measures and it can even be deobfuscated.
Are you sure all of this is needed ? Modifying a stolen code to make it work on another website can be harder/longer than just rewriting a similar code. Apart if you are doing something very special and new, I think you are just losing time by trying to protect your code.
I am wondering, because I got a website login script and it uses this command:
if(document.getElementById('linkreg'))
document.getElementById('linkreg').onclick = function ()
{
ajaxSend(php_fileusr, 'susr='+texts['register'], adboxshow);
objLogare.adLogInr();
return false;
};
Anyways, this function is triggered when the register for a new account (same thing for recovering account but different script). Anyways, some users weren't able to register because the window never popped up. I figured out that this is caused by the adblock extension. I am wondering if there is any way to replace the command adboxshow. Does anyone know any alternatives that work the same but won't be blocked?
Thanks to comments from Poke and Cezary, I figured it out
If I was an adblocker, and would see a function called adboxshow, I
would certainly block that as well. Can’t you rename it to something
more sensible? It does indeed sound as if you want to show an
advertising box here… – poke yesterday
Adblock is designed to block containers/scripts/css classes, that has
"ad*" prefix. You should avoid that, even if it's short for "awsome
dynamic" ;) – Cezary Daniel Nowak yesterday
I changed every function, class, or div that had the word "ad" in it, specifically starting with the word "ad" in order to make it compliant with ad blocker.
-I hope this helps others who are trying to make a website that has legitimate content that is not blocked by adblockers.
I want to create an extension to firefox using addon builder that
stops users from visiting a malicious website; When I see a URL that is
suspicious, I stop the page from loading and ask the user if he really
wants to visit the site. How could I implement that? I am expecting the functionality programmatically, so that I can make an extension.
if(site.is_malicious)
window.stop();
There is an event called beforescriptexecute supported my mozilla ..... Have a look , I think it will work the job for you. But what you desire can be done something like this:
var r=confirm("Are you sure you want to visit this site ?");
if (r==false) { window.stop(); }
You are creating a FF extension right? Why not use greasemonkey or so? You can execute a script BEFORE the page loads(on greasemonkey). when that script is called, you can potentially stop the pageload and throw an error message.
I'm trying to find a javascript method to delete flash cookies on a page, but with no luck.
I know it can be obviously done through flash or flex, but the problem is I know nothing about flash, flex and actionscripts...So my question is: Is there a way to just load a prebuilt flash movie in a page, which just programmatically deletes all the flash cookies it finds? Could any of you please make one for me? I could find some actionscript code around the internet and didn't look complex, but I don't know how to use it...
Thanks in advance!
A Flash cookie or SharedObject is defined with a name & a path. In order to clear it, you must first retrieve it using those values.
var mySoName:String = "name of your sharedObject";
var mySoPath:String = "path to your sharedObject";
var mySo:SharedObject = SharedObject.getLocal(mySoName , mySoPath);
After this you can simply call the clear() method to delete its data , the reference still remains though.
mySo.clear();
If you don't know what the values are for name & path, I'm afraid I don't know how you can deal with this.
I'm not sure that it's possible to delete ALL flash Shared Objects from a webpage.
The Flash sandboxing / security rules means that SOs aren't cross domain. This means that one site cannot poison or steal SOs for another site.
This (unfortunately for you) means that a site cannot delete ALL the SOs using Flash.
As far as I know, the only way to really remove all the SOs is to go do it yourself. (There's a few programs to manage / help you do this I believe)
There are global security settings which can block all new SOs from being created, but that doesn't (last time I looked) clear up the ones that already exist.