url in window.open is not working in IE - javascript

UPDATED
I have a page where i upload an image to crop which opens a window with the required functionality, it works absolutely fine as per below given script, but it doesn't work with IE
<script>
window.open('http://mymachine/mysite/crop.php?bgimagecode1=1281439586.jpg&x=728&y=364&id=30&bannersize=1x2&osCsid=','mywindow','fullscreen=yes,scrollbars=yes');
</script>
please help

Maybe you have IE set to block popups? You have to whiteflag the domain or it won't open. I would check your preferences.

If you are using PHP to generate this string, you should be using urlencode to make sure the URL's querystring is valid.

Don't set the second parameter. It doesn't work in IE... just leave it empty.
window.open('". HTTP_SERVER . "/crop.php?bgimagecode1=".$realname."&x=".$w."&y=".$h."& id=".$_POST['categoryId']."&bannersize=".$_POST['size']."&osCsid=".$_POST['sid']."','','fullscreen=yes,scrollbars=yes');
More info in a previous thread...

Related

A hyperlink download attribute not working

so i have this problem with hyperlink attribute download. basically i have link that download a certain file. however it doesnt work..
download file
With this format, it will download the file but it will give me an failed file says 'no file'.
On the other hand if i have link that has a complete uri format:
download file
It redirects me to the page and it will just show the file. The weird
thing is when I tried it on mozilla and brave browser. it works. but
in safari, and my default is google chrome. its not working..
Am I missing something? maybe in my header? really appreciate if you can help.. thanks!
EDITED
also, i've read this stuff about content disposition, so how do i know that my webpage set as inline for that matter.
it turns out, my problem is conflicted by same origin urls. Apprently, I am rquesting from different hosts/site, for further explanation see : https://developer.mozilla.org/en-US/docs/Web/Security/Same-origin_policy
If you look at here https://www.w3schools.com/TagS/tag_a.asp
Scroll down to attributes, and you will see that the DOWNLOAD attribute is only supported by HTML5, which, as it seems, your friend's version of Safari does not support. I recommend updating the program.
Alternatively, you can right-click on the download link, then click Save As..., then download it that way.
This may also be caused js intercepting navigation and redirecting. If so, you may be able to work around it by adding a target attribute.
download file.txt

Hitting a url better?

I've a ashx handler which outputs the file, when pinged.
As of now, I have it working by
window.open('url to ping');
I'm happy with the result. But however I'm interested in a better solution, since a user might have turned on popup blocker, which might result in file not downloading.
I can also use jquery ( if that helps )
You can simply use window.location = "http://pathtoyourhandler.ashx" instead.
With appropriate Content-Type the browser will stay on the current page and begin downloading the requested file.
If you do not want a window to open, you could always create a hidden <iframe> that has it's src property set to your link.
We used that work around when simply setting the location did not give the expected result (at least in IE8).
DEMO

size of popup window

How to set the width and height of a pop up window in html..
I used the following piece of code..
window.open('customerlist.jsp?salespersonid=<%=salespersonid%>&flag=<%=tempite%>','popupwindow','width=50 ,height=50')
It is working fine in IE but other browser displaying popup window in full screen instead of specified dimensions. What are the options for using in other browsers??
IE result:
Chrome result:
I recommend you use jquery for popups. Standard plugins render well in all browsers. You can start right away with jquery simple modal plugin. If you still want to use window.open , this link shall be very useful http://www.gtalbot.org/BugzillaSection/Bug195867GDR_WindowOpen.html .
With simple modal, you will have to include your popup html code in the same page over which you want to display it. Keep it inside a div. and then add this pi9ece of code
$(function(){
$(".your_button").click(){
$(".your_div").modal();
}
});
In chrome, you have to set "status=0" to get it to behave properly.
Maybe it can be the solution. I didnt try it.
w2=window.open("http://www.java2s.com","mywin","width=400,height=300,screenX=50,left=50,screenY=50,top=50,status=yes,menubar=yes");
Then you can connect to window that you opened.
w2.resizeTo( 400,300 );

Window.open not working IN IE

I have this function
window.open("<%=mcrforHyperLink%>&fromDate="+fromDate+"&interfacen="+interfacen+"&interfaceid="+interfaceid+"&toDate="+toDate,'name_' +Math.floor(Math.random()*11),'height=680,width=900');
This is not in IE , but working fine under Mozilla .
please help .
Internet Explorer can't handle window names that include a space. You don't have one, but I'd bet it also has problems when they include a . character (which you are generating with Math.random`). Make sure your name contains just alphanumerics.
Please explain why you are generating a random name for the window.
If you were to re-use it elsewhere I could understand.
This will do exactly the same unless there is something I have missed
window.open("...",'_blank','height=680,width=900');
(the ... is your url)
Also please notice that most modern browsers may BLOCK your window open unless instructed otherwise. If the url is from the same domain as the page with the script, I suggest you ajax it into the page you are on.

change url of tab javascript firefox extension

I am trying to change the url of a currently open tab in javascript firefox extension
Any pointers please?
I believe it's "gbrowser.loadURI()". Try reading this page on MDC about interacting with the global variable gBrowser, and here about the loadURI method.
The mozilla doc mentioned by TML has sample code for this under "Reusing by other criteria", but it's broken. The corresponding talk page says to add this line to fix it:
tabbrowser.loadURI(url, tabbrowser.currentURI, "UTF-8");
However, if you've already got the tab object (say from calling addTab earlier) then I think it's simpler to do:
gBrowser.selectedTab = mytab;
gBrowser.loadURI(myurl);
I don't see any way to change the URL of a tab which is NOT selected, but that would be nice - I hate stealing focus.
UPDATE: here's how you do it w/o selecting the tab. Simple:
gBrowser.getBrowserForTab(mytab).loadURI(myurl);

Categories

Resources