htaccess file nomenclature creating problem in opening a popup window in IE - javascript

My htaccess file nomenclature creating problem in opening a window in IE
EDITED
I have to open a colour picker which needs t be opened in popup, and I have
window.open('picker.html', null, "help=no,status=no,
scrollbars=no,resizable=no,toolbar=
no" + move + ",width=" + w + ",height=" + h + ",dependent=yes", true);
my base url goes like this:
http://www.mydoamin.com/
and the htaccess file has rewritten the above url from http://www.mydomain.com/30/
but when i wish to open the popup in IE the htaccess doesnt work for it and gives me url as http://www.mydomain.com/30/picker.html
and hence i get msg as broken link or NOT FOUND
there is no such folder called "30" the path has to be like http://www.mydomain.com/picker.html
The rewrite rule of the particular page goes like this:
RewriteRule
^30/order-vinyl-banners.html
order_form.php?id=30 [NC]
why is it happening..
please help me to track it..

If you want to show http://www.example.com/picker.html, you need to tell the open() function so. Right now you're telling it "Open the URL picker.html relative to where I'm currently at", but you want "Open picker.html relative to the root". Try this instead:
window.open('/picker.html', null,
"help=no,status=no,scrollbars=no,resizable=no,toolbar=no"
+ move + ",width=" + w + ",height=" + h + ",dependent=yes", true);

Related

Own Image Hosting Page: How to always open an html file but with image given in the url?

I'm currently working on my own image hosting site: https://img.baeni.de
Everything is working properly but I want to change something.
Currently, when opening a link from a shared image, it just simply opens the image. I want to open another html site with an image instead. The image should be the image which is given in the url.
Example:
Visiting img.baeni.de/u/123.png opens the construct.html file & sets so that the image, which is given in the url, will be shown on that page.
Important: The URL should still be img.baeni.de/u/123.png & NOT img.baeni.de/construct.html
I DON'T want to get spoonfeeded but want to receive some ideas of how you guys would handle something like that.
Best regards,
baeni
I am not sure, but this may work for you.
Put the following in a .htaccess in the u/ folder (or maybe the root folder).
RewriteCond %{SCRIPT_FILENAME} !-d
RewriteCond %{SCRIPT_FILENAME} !-f
RewriteRule ^u/(.*)$ construct.html?img=$1 [QSA]
When the visitor arrives at img.baeni.de/u/123.png the web server will actually serve the page img.baeni.de/construct.html?img=123.png.
You can use javascript like this to get the URL:
// Will get /u/123.png
var urlstr = window.location.pathname;
// Will turn it into 123.png
var imgstr = str.split("/").pop();
To load the image src after the page load, create a container (like a div) to hold the image. Then window.onload can populate this container with the image, or the error image.
<div id="image"></div>
<script>
// On page load call an immediately invoked function to load the image
window.onload(
function(){
// Will get /u/123.png
var urlstr = window.location.pathname;
// Will turn it into 123.png
var imgstr = "/gfx/" + str.split("/").pop();
// Error Image
var errorImg = '/gfx/error.png';
// Create the image in the div container
document.getElementById('image').innerHTML="<img src='" + imgstr + "' onerror='this.onerror=null;this.src=\"" + errorImg + "\"'>";
}()
);
</script>

Replace URL in address bar with a subdomain withOUT redirecting

I have total control over my entire domain and its subdomains, and I want to replace the URL displayed in the address bar with a subdomain but not redirect the page.
For example, when I load subdomain.mydomain.com?register I want the address bar to display register.mydomain.com without redirecting.
ALL pages and subdomains of mydomain.com already have document.domain = 'mydomain.com'; as the first thing in the $(window).load(function () { code of its external .js file.
I've tried history.pushState("", "", '/'); to strip away anything after the subdomain.mydomain.com (which works), and I've been able to display something after the / (which also works), but I can't get the displayed subdomain to change before the /.
How do I do this? Is it possible at all? If so, does it rely on document.domain? And if it does, am I executing document.domain properly??
Should I put
<script type="text/javascript">
document.domain = 'mydomain.com';
</script>
by itself in the <head> of my HTML files, or will it work just fine being in the $(window).load(function () { code of its external .js file?
I'm not sure about domain/subdomain things, but I have a page where a user can click multiple items and depending on his/her input, a URL that is displayed in browser's address bar changes. There is how I do it without redirecting:
var newurl = window.location.protocol
+ "//" + window.location.host + window.location.pathname
+ StrippedQueryString + '&H=' + Parameter;
if (history.replaceState) {
window.history.replaceState({ path: newurl }, '', newurl);
}
Hope this helps.

Prevent linked-in and tiwtter share to open in the same window

I use the same code(Except the height parameter) to open linked-in and twitter share windows
window.open(
url,
title,
'_blank,directories=no,titlebar=no,toolbar=no,location=no,status=no,menubar=no,=no,width='
+ width + ', height=' + height + ', left=' + x + ',top=' + y
);
But they are replace each other and not opened in separate windows.
How do i open them in different windows.
The second argument to the window.open() function gives a name to the window being opened. If you use the same name as an existing window then that window is re-used. You set that argument from your title variable, so make sure your title is different for your Twitter and Linked-in windows and then they'll open in separate windows.
(If you want a new window every time then set the second argument as "_blank".)
Further reading: MDN's window.open() page

window.location.href causing animated gif loader to freeze in Firefox

I have a link which when clicked redirects the user to the same page except with additional parameters:
<a id="lnkExportToPDF" href="javascript:void(0)">Export</a>
$('#lnkExportToPDF').click(function (e) {
e.preventDefault();
window.location.href = path + 'users/export/' + parm1 + '/' + parm2;
});
On the server side I handle it by checking for "export" in the request path, and if it's found I write a PDF file to the response:
System.Web.HttpResponse response = System.Web.HttpContext.Current.Response;
response.Clear();
response.AddHeader("Content-Type", "application/pdf");
response.AddHeader("Content-Disposition", String.Format("attachment; filename=" + filename + ".pdf; size={0}", buffer.Length.ToString()));
response.BinaryWrite(buffer);
response.End();
Everything works and the user can download the file, but any additional actions by the user that uses the loader.gif which is on the page shows an unanimated loader.
What could be causing this to happen? Is there any way to refresh/reload the page/javascript after the response is complete?
edit: I've found a useful JS tool here: http://fgnass.github.io/spin.js/ but I'd prefer not to use it unless absolutely necessary
edit2: I also tried using a generic handler (.ashx) to handle the request (ie. changing the href to point to the handler), but as soon as the page redirects and the file is written, same thing happens
edit3: The problem is only happening in Firefox so far. I've tried Chrome and IE and the gif stays animated in those browsers. (latest versions of each)
edit4: If I use an iframe with the src as the image it solves the issue, but it's very hacky and the style of it looks different across all browsers with regards to centering/padding/margins.
edit5: Yeah. If I inspect the frozen gif with firebug it magically unfreezes itself.
I managed to recreate the problem in firefox and I really can't find a way to "unfreeze" the gif. When I added a completely different file after a download and that too was frozen I gave up with that approach.
What I did instead was to test different ways to trigger the download. I found no window.location solutions that worked, what did work though was this:
window.open(path + 'users/export/' + parm1 + '/' + parm2);
window.open opens a new tab and downloads the file through that instead of the current tab as window.location does. It will return to the current tab as soon as the download starts.
Edit
You could also use a hidden iframe:
var iframe = document.getElementById('iframe');
iframe.src = path + 'users/export/' + parm1 + '/' + parm2;
I confirm that I have the same behavior with firefox, and the first that come to my mind is to use SetTimeOut but still the same behavior, so on firefox for some reason, this window.location.href is also call the "Stop" on browser, that this cause the gif animation to stop.
So what I found and you can solve your issue, that this is not happends on simple links.
And if you change your code you can archive the same effect with a link.
So change this
$('#lnkExportToPDF').click(function (e) {
e.preventDefault();
window.location.href = "page.aspx";
});
to something like this
$('#lnkExportToPDF').attr("href", "page.aspx");
and you have the same results, and gif will still moving.
Here is the fiddle test.
On the test I add to move to paypal, because is slow moving and you can see the animation stop or not, also pp not let show on iframe, so on example you stay on example and not load the page.
When you click on this example, the issue is appears only on firefox !
http://jsfiddle.net/hn7S9/4/
One other issue that I think is that if you need to make your parametres to the next page on click, you probably need to redesign that and fix them before your click.
This is possible because for sure is not depends on the last click on the dynamic create link. So make the link with their parametres before the click.
You could try an asynchronous approach on the click to allow the browser to parse the event queue after the click has initiated:
$('#lnkExportToPDF').click(function (e) {
e.preventDefault();
setTimout(function() {
window.location.href = path + 'users/export/' + parm1 + '/' + parm2;
}, 20);
});
How about allowing the link to actually fire, but opening it in a new tab?
That shouldn't interrupt anything about the gif, and is semantically fine, other than I guess it would leave a tab open. You could get rid of the content-disposition, and allow the browser /user to decide what to do with it though.
<a id="lnkExportToPDF" target="_blank">Export</a>
$('#lnkExportToPDF').click(function (e) {
$(this).attr("href", path + 'users/export/' + parm1 + '/' + parm2);
});
Instead of setting the window.location.href, you can use a form with method="get" and submit it. This form could either be coded into your HTML or created dynamically. See this Answer:
https://stackoverflow.com/a/21742326/1614903
Here's my solution. It's faster and easier than any fix or workaround I've found. Just open the problem page in Chrome. Chrome has it's own problems, but this isn't one of them. Whenever I encounter a page full of gifs that causes Firefox to freeze, I just copy the URL, close the tab, open Chrome, and paste in the URL. I works every time! :o)

window.openDialog does not remove the titlebar on linux

I use the following code to display a popup:
var win = window.openDialog("chrome://broceliand/content/view/popup/nameMapPopup.xul",
"",
"all=no," +
"titlebar=no," +
"chrome=yes," +
"toolbar=no," +
"dialog=no," +
"resizable=no," +
"modal=yes," +
"dependent=yes," +
"top="+popupY+"px," +
"left="+popupX+"px",
args);
On windows the popup is pretty clean. There are no common elements remaining.
But on linux le titlebar still remains and the popup is resizable.
Try setting the hidechrome attribute on the window element to true. See https://developer.mozilla.org/en/xul/window
That might be because on Linux the window decorator is responsible for the titlebar. This can even be a seperate program to the window manager.
Does the popup need to be as a seperate window? Perhaps panel is really what you are looking for.

Categories