I have modified Microsoft's LSP (Winsosk Layered Service Provider) example to make web filter application for desktop. I am able to block access to websites by comparing host in http header to a list of banned websites in a file. If a web is blocked, LSP will fill the buffer with html page showing that this page is banned. I tested on Firefox 4, Opera 11 and IE 6, and a block page is shown. However, such page not shown in Chrome 11 (the latest).
I wondered if Chrome handle LSP differently.
This is buffer that I feed into LSP WSPRecv function.
string strBufferHdr;
char len[10];
_itoa_s (strBufferHTML.size(), len, 10);
strBufferHdr += "HTTP/1.1 200 OK\r\n";
strBufferHdr += "content-type: text/html; charset=UTF-8\r\n";
strBufferHdr += "connection: close\r\n";
strBufferHdr += "content-length: ";
strBufferHdr += len;
strBufferHdr += "\r\n\r\n";
strBufferHdr += strBufferHTML;
strBufferHdr += "\n\n\n";
strBufferHTML is a html page content.
Thank you.
Chrome uses overlapped I/O, so you need to put your code where WSPRecv is called in overlap.cpp in addition to spi.cpp. (Filenames from the nonifslsp SDK sample.)
Related
Having an issue with Firefox 46, on all the other browsers it work fine.
Upon exit from the page I ask the following question. Firefox ignores it completely.
Help please!
window.onbeforeunload = ThisCheckExittingPage;
var ThisCheckExitWindow = 1;
// Checks before exitting
// ThisCheckExitWindow = 1;
// Does NOT check before exitting
// ThisCheckExitWindow = 0;
function ThisCheckExittingPage() {
if (ThisCheckExitWindow == 1)
{
return "You are about to exit this page.";
}
}
This looks like by design, as WindowEventHandlers.onbeforeunload - Web APIs | MDN has this note:
To combat unwanted pop-ups, browsers may not display prompts created
in beforeunload event handlers unless the page has been interacted
with. Firefox has implemented this policy since Firefox 44 (Bugzilla).
As the relevant patch shows, the mUserHasInteracted flag variable is set after a mouse or keyboard event happens in the window.
I am opening a popup window from CRM 2011 for Outlook. The problem is I need the user to be able to print. If you do it from IE the browser print menu is available but from Outlook it is not. You just get a plain window. Hitting the Alt key does nothing when a popup opens from Outlook. None of the openStdWin() options seem to actually work from Outlook.
FYI I'm trying to print Dashboards (why MS left that out is beyond me). The solution we came up with is the following code hooked to a ribbon button. Then the user uses the built-in browser print functionality and the dashboard can be printed. But not from Outlook it seems. Any suggestions? (before anybody suggests it our client thinks print-screen is unacceptable)
function printCurrentDashboard() {
if (Xrm.Page.context.isOutlookClient()) {
var pTarget = document.getElementById('dashboardFrame').src;
openStdWin(window.location.protocol + '//' + window.location.host + pTarget, 'test', 800, 600, 'menubar=yes,toolbar=yes,channelmode=no,directories=yes,fullscreen=no,location=yes,status=yes,titlebar=yes');
}
else {
var pTarget = parent.document.getElementById('dashboardFrame').src;
window.open(window.location.protocol + '//' + window.location.host + pTarget);
}
}
Try using openStdWinWithFeatures vs openStdWin.
I am trying to remove an element on AJAX success which was loaded and attached to the document during a previous AJAX call.
My code looks something like this:
$("#jobs-table-body").on("click", ".one-rc-button", function() {
var ctx = $.parseJSON($(this).siblings(".context").html());
$("#one-rc-candidate-id").val(ctx.candidateId);
$("#one-rc-job-id").val(ctx.jobId);
var loader = $("#wrapper").loader();
$.post($("#one-rc-form").attr("action"), $("#one-rc-form").serialize(), function(result) {
loader.remove();
if(result.success) {
// This works and returns 1
alert($("#candidate-row-" + result.rejectedCandidateId).length);
// This doesn't seem to be doing anything
$("#candidate-row-" + result.rejectedCandidateId).remove();
} else {
//$("#one-jc-messages").html(result.error);
}
});
});
The elements .one-rc-button and #candidate-row-<candidateId> were loaded by a previous AJAX call and they are attached to the document as I can very well see them on my page.
Now, on click of the previously generated .one-rc-button, I trigger a second AJAX call (which works fine) and on result.success, I want to delete the #candidate-row-<candidateId> (which is within the previously generated parent element).
The alert works and returns 1. So I know for sure that the selector is fine and it is matching one unique element.
What I don't understand is why it is unable to remove the element from the page.
Observations
I use Firefox 10.0.2 where this problem is reproducible.
On IE 8, it works (element gets removed)
On debugging the script on Firebug, I can verify that I have got a handle to the right eleemnt.
Try using FireBug to set a breakpoint on that line so you can see exactly what it's getting from that selector. Ideally break up the statement first, like this:
var unwantedDiv = $("#candidate-row-" + result.rejectedCandidateId);
unwantedDiv.remove(); // <-- Set a breakpoint on this line
You can then look at the unwantedDiv variable in the watch pane on the right of the firebug debugger and see what it is, what methods it has/has not got etc. I would assume that you are not getting back exactly what you think you are, possibly because of how you attached the div after the previous AJAX call. More information about JavaScript debugging with FireBug here.
Another option is to turn on strict warnings in the firebug console and see if you get any 'undefined method' errors, which don't stop the show on FireFox, but just bounce you out of that function. Do you get an error in IE?
Solved it by a really ugly workaround. I am still not sure what causes this behaviour.
if(result.success) {
var removeThis = $("#candidate-row-" + result.rejectedCandidateId);
removeThis.remove();
removeThis = $("#candidate-row-" + result.rejectedCandidateId);
if(removeThis.length != 0) {
removeThis.remove();
}
}
Now it works on both Firefox and IE.
i'm developing a firefox extension and i want to be able to close a specific tab. For example if there are many open tabs in the browser o want to close only the tab with a specific url.
I know that i can use gBrowser.removeTab(tab) but i don't know how to get tab object.
On the other hand i can get the browser that corresponds to the url but the param of the removeTab() function must be a "tab object". How cat i get the tab object.
Any ideas?
tabbrowser.getBrowserForTab() method is actually the easiest way of associating browsers with tabs. So you would do something like this:
var tabs = gBrowser.tabs;
for (var i = tabs.length - 1; i >= 0; i--)
{
var tab = tabs[i];
var browser = gBrowser.getBrowserForTab(tab);
if (browser.currentURI && browser.currentURI.spec == "...")
gBrowser.removeTab(tab);
}
I think you can use this method: gBrowser.removeCurrentTab(); this example closes the currently selected tab.
For more code, please refers this link: https://developer.mozilla.org/en/Code_snippets/Tabbed_browser
I cannot find an answer on the following issue. I have managed to reload a specific part of my page (page A) by using AJAX (through document.getElementById). I would like to know if there is a way to choose which part of the document (page B) will be used to reload the content of page A. In other words, pick a specific DIV from a 2nd page (same domain) and use it to refresh the contents of my page. I have seen in other threads that it is not possible to do it with pages that aren't from the same domain. But in my case I will use a page from the same domain. Any ideas?
Thanks.
If you have page A loaded and your scripts run there, so this will do:
var ifr = document.createElement('iframe');
ifr.src = 'page B URL';
ifr.style.position = 'absolute';
ifr.style.left = '-1000px';
ifr.onload = function() {
document.getElementById('page A div id').innerHTML =
ifr.contentDocument.getElementById('page B div id');
}
document.getElementsByTagName('body')[0].appendChild(ifr);
Note: page B loads and runs completely. If you need the only div to be passed through the Internet connection, you need to implement server side logic.