I've run into this and while the internet seems to be full of answers and discussions on this issue nothing seems to be working.
I'm building a mobile web page where I run a jQuery JavaScript function off a submit button, it calls an AJAX query comes back does it's business and then I get to the dreaded:
window.location = "url";
Now I've personally tried every version of this I've seen deprecated or not:
window.location.href =
window.location.replace() --I know this is achieving something different
window.location.assign()
window.navigate()
document.location =
document.location.href =
document.location.replace()
document.location.assign()
In each instance my Android Browser version 5.5 just stops at the point it is supposed to move through to the next url. I'm using full urls from the "http://..." so not missing that.
In contrast Android Chrome is moving through like a champ. Same Phone. Have I missed some crucially important piece to the puzzle here to get this moving on Android Browser?
My searches online seem to only say that:
window.location.href = '';
...is the most technically correct, right now I'd settle for working rather than technically correct.
If anyone has any ideas or at least some avenues to go off and explore I'll get all over that first thing in the morning.
Thanks for any help you can offer.
I found that this was a result of a faulty AJAX call. The weird thing that was throwing me off was that some items would work within the call (even though the call failed) and some would not.
The answer in my own case was to fix the PHP that the AJAX was calling and then changing pages worked as I would expect it to.
Related
I have a web app functioning from the last two years but after updating some features and adding a new page I starting getting an error that Page not found.
When I looked further I got to know it is because of User Parameter in the URL which can be seen in screenshots '/u/1' is being added in my script URL Automatically as click on a link.
I tried removing it manually but it doesn't help, I have tried several modes of deployment.
And if I roll back to my older version it still works fine or if I log in only with a single account it works with the new version as well.
So I wanted some light is possible to overcome this issue?
I am just a part-time coder who can create something based on my needs so even after looking for the whole day I couldn't get it working so as of now I have rolled back to the old version.
Thanks in advance I am more than happy to share any more info required.
Screenshots attached with URL difference and error.
So I was able to find a workaround after roaming around in Google Forum as well they stated that it can not be solved since its intended behavior.
so what I did was done some modification in my function which was being used to get script URL and added some desired string to overcome user specific error when logged in with multiple users.
Here is the code
function getScriptUrl() {
var url = ScriptApp.getService().getUrl();
var stringToBeChanged = 'macros/s';
var newString = 'a/authentic.co.in/macros/s';
url = url.replace(stringToBeChanged,newString);
return url;
}
I hope this helps someone with a similar issue thank you for your support.
I'm trying to use this simple code:
javascript:document.getElementsByName("tabla-usuarios_length")[0].options[3].text="10000";
I tested it on Chrome(URL) and it works perfectly, also in both Firefox and Google Chrome's Console.
In both console's it works and it gives me like a message "10000" in the console.
In Firefox URL, it redirects like to a blank page with that same message instead of just working on the page I am. so since it goes to that blank page I can't see the results and to come back to the page I was I have to tap on back and of course it reloads losing the possible change that I made with the JS code..
I really need it working with the url stuff since I need to use it with iMacros (URL GOTO=javascript:....) so I can't use it with Console.
Thanks I hope I explained myself correctly.
Three alternatives
wrap a simple command in void()
javascript:void(document.getElementsByName("tabla-usuarios_length")[0].options[3].text="10000");
or - use IIFE
javascript:(function() {document.getElementsByName("tabla-usuarios_length")[0].options[3].text="10000";})();
or, again only with simple command, use , operator like so:
javascript:document.getElementsByName("tabla-usuarios_length")[0].options[3].text="10000",undefined;
Seems Firefox looks at the return value of bookmarklets. If it is udefined it works as expected
All complex bookmarklets I've ever seen were always wrapped in IIFE - which is why they've always worked
Even the wikipedia page (which I only now read) shows this requirement - with one other format for them
javascript:{arbitrary script};void(0);
I'm trying to set the value of a textarea on the following page by executing something similar the below javascript:
javascript:alert(document.getElementsByClassName('uiTextareaNoResize uiTextareaAutogrow _1rv DOMControl_placeholder')[0].value='blabla');
This works if I manually enter the code into the address bar on the target page, but I want to pass this argument through a link.. ie...
<a href="/nextpage.php?javascript:alert(document.getElementsByClassName('uiTextareaNoResize uiTextareaAutogrow _1rv DOMControl_placeholder')[0].value='blabla');"
Just wondered if anything like this is possible at all?
You can send the arguments via the url like you would for GET requests. Then have the receiving page parse location.search.
For instance, you can send it like this:
http://example.com/?arg1=foo&arg2=bar
And the receiving page have a script like this:
var queryString = location.search; //?arg1=foo&arg2=bar
You'll have to parse it manually though, removing the ?, split by & then each by =
This is called XSS or Cross-Site-Scripting, and as many comments have already pointed out, it is a security issue. This is why most major browsers do NOT allow it.
However, I believe that some browsers do allow it, for example Opera - although I can't recall exactly which version.
If you are looking to make your own "browser", I would recommend using C# .Net WebBrowser, then use the runtime package XULRunner (https://developer.mozilla.org/en-US/docs/Mozilla/Projects/XULRunner).
Despite all this, I would not recommend doing anything that may be against laws of your current location, or doing anything to displease the site owner.
I try to have some content loaded on Wordpress thanks to Jquery .load(). Sometimes, when my code is OK, it's not working anymore the day after...
I'm trying to narrow the causes. First I thought it was a syntax problem or a single/double quote mix up, but since it worked once, there is no reason syntax or error is involved.
I thought about bad cache settings but shift+F5 won't break my working code.
And now I just tried, with a perfectly working code, to close and restart WAMPserver. And Bingo, when I restart the server it's impossible to get my load function to work (the same from 1 min before...) !
EDIT: I just replaced the code (below) with the one I'm using now
$(document).ready(function(){
$.ajaxSetup({cache:false});
$("#portfolio-list li:not(#DrawerContainer)").click(function(){
var post_link = $(this)
//.parentsUntil(".ProjectWrap")
//.parent()
.find('.mosaic-backdrop')
.attr("href");
console.debug(post_link); //to get post_link info in the console
$('#DrawerContainer').remove(); // remove existing, if any
$('<li/>').attr('id', 'DrawerContainer').css({display: 'none'}).data('citem', this).html("loading...").load(post_link + " #container > * ").insertAfter(LastInRow).slideDown(500);
return false;
});
});
When the function isn't working, I try to remove the part .load(post_link + " #container > * "); and replace it with the part just after (a complete url). Usually it works and at least I can continue styling my page, but I have to fix the problem.
What can cause this weird behavior? Can WAMPserver rewrite something while closing?
Is there an option I could check?
Although this was solved in the question's comments, here is an answer for anybody skimming the page.
There is an issue with running ajax requests across different domains. Your WAMPserver does not like it and will stop it unless you tell it otherwise. Although you are working locally, WAMPserver thinks http://localhost/ is different to http://127.0.0.1/.
To get around this, in the file that handles your ajax add this:
<?php header('Access-Control-Allow-Origin: *'); ?>
Note, you can change the * for a URL too (e.g. http://127.0.0.1/
If that does not work, you may have to change settings on your server.
I have some code that generates URLs to be used in various places across a site (image src, link hrefs, etc). I am seeing lines in the access logs which show some of the javascript code that generates the URLs masquerading as a file request.
For example, "/this.getIconSrc()" is one that I'm seeing quite a bit. I can't figure out how or why this is occurring and I can't manage to reproduce it without actually entering "http://whateverthesiteis.com/this.getIconSrc()" into the location bar. In most cases, these functions are chained together to generate a URL but the whole function chain does not appear in the server logs, just part of it.
I've probably invested around 30 hours trying to figure out why this is happening but cannot. It doesn't appear to be a browser issue as I've tried in IE 6/7, FF 2/3, Opera, Safari 3, and the problem does not occur. Has anyone else experienced something similar and, if so, what was the solution?
There's three possibilities really:
A bug in your HTML - malformed HTML causing onclick to leak into href, for example
A bug in your Javascript - myIcon.src = 'this.getIconSrc()'; - note the quotes that shouldn't be there
A poorly-written spider is hitting your site (like #Diodeus said: ___)
Edit:
Check the User Agent and Referrer in your logs - they may offer a clue.
Are you generating JavaScript calls like this? This may explain it.
___
#RoBorg... I'm thinking the most likely scenario is #3 since this particular function is actually only called in one place...
function whatever(){
var src = this.getIconSrc();
return src.replace( /((?:https?:\/\/)?(?:[^\/]+\/)*)[^\/]+/, '$1newimage.png' );
}