w3hello.com logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML videos Categories
How to disable external javascript execution / site requests in phantomjs
To filter invalid requests, you could use the onResourceRequested callback : this allow you to abort unwanted urls. Here is a basic example for stackoverflow. var system = require('system'); var page = require('webpage').create(); var domain = 'stackoverflow.com' var url = 'http://www.stackoverflow.com'; page.onResourceRequested = function (requestData, networkRequest) { if (requestData.url.indexOf('.js')===-1 && requestData.url.indexOf(domain) === -1) { networkRequest.abort(); console.log('aborted :'+ requestData.url) } }; page.onResourceReceived = function (response) { console.log('Response (#' + response.url + ', stage "' + response.stage + '"): '); }; if (system.args.length !== 1) { console.log("Usage: phantomjs filter.js url"); } else {

Categories : C#

Can Watir-Webdriver with PhantomJS access an external URL that has basic auth?
caps = { 'phantomjs.page.settings.userName' => 'admin', 'phantomjs.page.settings.password' => 'password' } driver = Selenium::WebDriver.for(:phantomjs, :desired_capabilites => caps) browser = Watir::Browser.new(driver) browser.goto 'https://test.website.com'

Categories : Ruby

Phantomjs - take screenshot of a web page
I am going to assume you have installed Phantomjs and have created an alias in your .bashrc or have updated your system path to call the Phantomjs binaries. If not, you need to peruse a few beginner tutorials: http://net.tutsplus.com/tutorials/javascript-ajax/testing-javascript-with-phantomjs/ Once you have that set up, you will need to write a simple javascript file that you will call in the terminal (or shell, if you are using Windows). I will provide a simple, example script below. var WebPage = require('webpage'); page = WebPage.create(); page.open('http://google.com'); page.onLoadFinished = function() { page.render('googleScreenShot' + '.png'); phantom.exit();} Then, save your js file. Open up your terminal or shell and run the following phantomjs yourFile.js That's it. C

Categories : Javascript

Generate single-page .pdf with PhantomJS
viewportSize simulates the size of the window like in a traditional browser. It affects the rendering of the page because of HTML layout but not directly pdf rendering. Use page.papersize to define the size of the web page when rendered as a PDF. With a bit of Jquery, it's easy to render the web page in a single document, like this : var page = require('webpage').create(), system = require('system'), address, output; if (system.args.length != 3) { console.log('Usage: spdf.js URL filename'); phantom.exit(1); } else { address = system.args[1]; output = system.args[2]; page.viewportSize = { width: 600, height: 600 }; page.open(address, function (status) { if (status !== 'success') { console.log('Unable to load the address!');

Categories : Javascript

PhantomJs - How to render a multi page PDF
Just need to specify a paperSize. Like this with module "phantom": "0.5.1" function(next) { phantom.create(function(doc) { next(null, doc); }, "phantomjs", Math.floor(Math.random()*(65535-49152+1)+49152)); }, function(ph, next) { ph.createPage(function(doc) { next(null, doc); }); }, function(page, next) { page.set('paperSize', {format: 'A4', orientation: 'portrait'}); page.set('zoomFactor', 1); } Then, simply use page-break-before: always; in your HTML content each time you want to open a new page. PS: I use async.waterfall in this example PPS: Math.random on port number is used to avoid module crash if concurrent calls to phantom binary are triggered. Works fine - if someone wants to post something better even if a bit off-topic, feel free to

Categories : Node Js

Why am I not receiving phantomjs page response?
page.open() is asynchronous. So the line with phantom.exit() will be executed before the page has been loaded and this stops the PhantomJS process. Move the phantom.exit() inside the callback for page.open() and place it at the end of the callback (i.e., after your processing code). So basically you will have this: page.open('http://local.example.com:9001/test/workflow', function() { console.log('page opened'); phantom.exit(); });

Categories : Javascript

PhantomJS: getting the rendered dimensions of a page
Try using the page.onLoadFinished callback: var wp = require('webpage'); var page = wp.create(); page.viewportSize = { width: 1024, height: 768}; page.open(url); page.onLoadFinished = function() { var f = "rendered.png"; //Produces an image with height 4073px page.render(f); //height is only 150 var height = page.evaluate(function() { return document.body.offsetHeight }), width = page.evaluate(function() { return document.body.offsetWidth }); console.log(height,width); }; This should return the correct height and width after the page content has finished loading. I think the difference is that page.onLoadFinished waits for all content to finish loading and not just for a 200 OK response which is equivalent to the success status.

Categories : Javascript

How to get updated page content after a JS event using phantomjs?
So your page.evaluate() call has a side effect and that changes the page. The question is whether this change occurs instantaneously. But you cannot assume that it does - particularly if it causes a fetch of new content from a remote webserver. That being the case the best thing you can try is to sleep for a while and then assume your page has the new content. Or alternatively, when you feel more advanced, poll on a regular basis for a DOM object you are expecting to appear. But the beginner should try a sleep: .... page.evaluate( function() { ... } ); window.setTimeout( function() { /* press submit button */ }, 5000 /* wait 5 seconds (5,000ms) */ ); ....

Categories : Javascript

using squishit and rendering external minifiedjs at the end of body element
You probably don't want to do things this way. The cached/named bundles are for scenarios where you can't (or don't want to) create physical files. The way you're doing it here just creates more complexity. Bundle.JavaScript().Add("~/file.js").Render("~/blah") will still cache the bundle, but it uses the file on disk (only created once). Are you really calling Bundle.Css().RenderNamed("javascript bundle name")? If so you need to change the call to Bundle.JavaScript().RenderNamed. If this is just a typo it would help to see more code / markup.

Categories : Javascript

Capybara Poltergeist/PhantomJS testing - disable javascript on a page
So, I still have no idea how to do this in Poltergeist, but I figured out how to get it set up in Selenium: Capybara.register_driver :selenium_firefox_nojs do |app| profile = Selenium::WebDriver::Firefox::Profile.new profile["javascript.enabled"] = false Capybara::Selenium::Driver.new(app, :browser => :firefox, :profile => profile) end

Categories : Ruby On Rails

in rendering plugin external font imported by css is not working when download pdf
I had the same problem and I resolved by using absolute url in the css link: <link rel="stylesheet" type="text/css" href="${grailsApplication.config.grails.serverURL}/css/pdf.css" media="all" /> and I also excluded CSS and all used resources from the resource plugin: grails.resources.adhoc.excludes = ['/css/pdf.css','/images/background.png', '/css/SectionUnicode.ttf']

Categories : CSS

Login page doesn't get fully loaded using selenium webdriver and PhantomJS
Try this: driver = webdriver.PhantomJS(service_args=['--ignore-ssl-errors=true']) Give credit to: ashemedai commented on 9 Aug 2013 at: https://github.com/detro/ghostdriver/issues/233

Categories : Python

How to optimize PhantomJS for search engines to index a single page application?
You can use some command line switches to improve the capture performance: First, you can ignore all images with --load-images=no. There's no need to load images when doing the HTML snapshots. You can also enable the cache with --disk-cache=yes (use --max-disk-cache-size to set its size in bytes) Finally, the WebPage#onResourceRequested callback may also be useful to abort some requests (trackers, media files...) with the NetworkRequest#abort method.

Categories : Selenium

Make a ajaxcall from my js(local apache) to an asp page (local iis)
In the asp file : Call response.AddHeader("Access-Control-Allow-Origin", "*") response.write("bravo") And it work well. With this line in the js : $.get('http://localhost/Local-Site-A/test_ajax.asp', function(response) { console.log(response); });

Categories : PHP

Use local sourcemap with external sources
There is: Specify //# sourceMappingURL=http://localhost/xxx.js.map as the last line of your script and have a local web server (behind a foirewall) supplying it. Works fine for me.

Categories : Misc

How can I fetch a web page with external resources like browsers "save complete web page"?
You can use wget and its recursive download ability. http://www.gnu.org/software/wget/manual/wget.html#Recursive-Download $ wget -r or $ wget --page-requisites

Categories : Javascript

Will SQL Server treat a USB 3.0 External Drive as local?
I just used a USB 2.0 drive the other day to perform a restore to a test environment. I imagine that as long as Windows identifies the drive as a local disk and not removable storage, and the SQL Server service can access the directory, it should work just fine.

Categories : Sql Server

Local Interface to an external SOAP web service (C#)
Create an abstract method in CurrencyConvertor that is called GetService(); the deriving classes will have to implement this method in the way that they return the service ... in CurrencyConverter: public abstract IMyNewServiceThingy GetService(); The base class can now use this class to get the service and call methods on it In every deriving class: public override IMyNewServiceThingy GetService() { return Service; } Setting the Service variable on class - levlel is a bad decision, even worse, when you reset it when creating a derived class (in the constructors) - you can never know which Service is currently set.. (esp. when using IOC or asynchronous calls)

Categories : C#

How to handle external sub prototype with local AUTOLOAD in Perl
To anyone having a similar problem, this is what I've found so far: You can only define prototypes at compile time, otherwise they are ignored. If you know the name of the function at compile time but plan on loading code for the symbol later (at run time), then you can just define the prototype without code: sub some_sub(@$); If you don't know the name of the function but you can get it dynamically ar compile time, then you can use Scalar::Util::set_prototype to declare the local prototype only: package MyModule; use strict; use Scalar::Util qw(set_prototype); my $protos; BEGIN { # compile time my @functions; # Imagine you load here @functions with hashrefs containing name and proto values. no strict 'refs' for my $i (@functions) { # Thi

Categories : Perl

how to use local resources in external non-Activity classes (plugins)?
OK, not sure there is anyone interested in, as I had so few viewers in more than two weeks, but I figured out a solution, and maybe it could be usefull for someone else, so I'm posting here. The point is that I cannot access plugin R class, so I have to find a workaround into the method getInflatedBox: Resources pgResources = null; Context pgCtx = actContext.createPackageContext(packName, Context.CONTEXT_IGNORE_SECURITY); pgResources = pgCtx.getResources(); int lLayoutID = pgResources.getIdentifier(layoutName, "layout", pgPackName); View.inflate(pgCtx , lLayoutID, root); where actContext is the context of the calling main activity. Practically I obtain the right ID for the layout I want to inflate obtaining a pointer to the actual resources of the plugin throught the local context pgC

Categories : Android

Submitting a form to external link (but a local action before doing so)
I would submit a JSF form via AJAX behind the scenes first and when the response arrives I would submit your plain HTML form to an external URL. Example: <script type="text/javascript"> function jsf(data) { if(data.status == 'success') { document.getElementById('plain-submit').click(); } } function normal() { document.getElementById('jsf-submit').click(); } </script> ... <h:form prependId="false"> ... <h:commandButton id="jsf-submit" action="#{bean.action} value="Submit" style="display:none"> <f:ajax execute="@form" ... onevent="jsf"/> </h:commandButton> </h:form> <form method="POST" action="https://EXTERNAL-LINK.com/"> ... <input id="button-submit" type="but

Categories : Java

AJAX load external page div into current page
You cannot use a CSS selector in a remote document via AJAX like you're trying. The #single_portfolio after the URL would act as a hash (w/o the space in front). You need a URL that returns exactly what you need for your AJAX call. Alternatively, you can fetch the entire page, and do some processing in the callback function to extract the desired part.

Categories : Jquery

Run web application from local machine and host files on external server
If I understand correctly, just change the STATIC_URL in the settings.py to the server the holds the static files: in settings.py: STATIC_URL = 'http://staticserver/path/to/static/on/apache' (make sure the change media_url as well if needed)

Categories : Mysql

Slide external page on top of current page
Load your content into a off-screen or invisible div, then .animate() the div into place. You can also change the class names accordingly, thus applying all the styles to your brought in div. The folks over at GitHub implemented that idea a while back: https://github.com/blog/760-the-tree-slider

Categories : Javascript

Redirect domain name mapped with external IP (modem) to a host in its local network
If you want to redirect my domain to the particular host you need to setup NAT-Virtual Server Setup . here you need to map remote port to internal map. In above image IP address is my IP of my host and Default address is my router's IP address Now you have configure NAT in you router as bellow. in above image server IP is you host IP address. I am using D-Link router so this Image is according to that if you are using some different router then you might have different view. After configuring this when you type EXTERNAL_IP:80 your request will be forwarded to application that is running on you host with that port

Categories : Networking

halting pdf.js page rendering
If I understand well your problem, I might have a solution. When I clicked too fast on the buttons previous or next, the canvas had not the time to refresh, and two (or more) pages where drawn, it was unreadable. To solve the problem, I use the following code : var stop = false; function goPrevious() { if (pageNum > 1 && !stop) { stop = true; pageNum--; renderPage(pageNum); } } function goNext() { if (pageNum < pdfDoc.numPages && !stop) { stop = true; pageNum++; renderPage(pageNum); } } I have also modified the render function in the pdf.js file : render: function PDFPageProxy_render(params) { this.renderInProgress = true; var promise = new Promise(); var stats = this.st

Categories : Pdf

getting NPE exception on rendering of page
was just looking into webflow problems,and even if it is not your main concern, i may have found a partial explanation for the when your bug occurs and when not. The "on-entry" expression code is only executed when this view-state is accessed from the webflow logic, and is not if you access this flow state from a refresh or direct access to a previously rendered view (by typing directly in url .... = e1s5 for e.g.) It does not solve your problem but i think it could explain the conditions of its reproduction. Your actions are always leading to an unhandled error (to investigate in your java code), but your actions are not always executed. You could check on that by moving your actions to an "on-render" section instead, and then your error should show up every time you acces this view,

Categories : Spring

CSS incompetent - cannot figure out why my page is rendering the way it is
EDIT: Ok, better answer I think. Try this: .dropdowns_bar li { display: inline-block; } .buttons { display:block; margin-top:10px; } .buttons li { display: inline-block; }

Categories : Javascript

JSP page not rendering properly when served from WAR
If I recall correctly the JSPs should be placed directly inside the project folder and not inside WEB-INF. You can try that and change the web.xml <welcome-file-list> <welcome-file>testPage.jsp</welcome-file> </welcome-file-list>

Categories : Tomcat

Edit formulas of multiple workbooks to remove external references / change the reference to the local workbook
This is a version of the original macro with added code to fix the formulas. Sub Example() Dim path As String Dim file As String Dim wkbk As Workbook Dim rCell As Range Application.ScreenUpdating = False Application.DisplayAlerts = False path = "C:Test" file = Dir(path) Do While Not file = "" Workbooks.Open (path & file) Set wkbk = ActiveWorkbook Sheets.Add After:=Sheets(Sheets.Count) On Error GoTo Sheet_Exists ActiveSheet.Name = "DB Output" On Error GoTo 0 ThisWorkbook.Sheets("DB Output").Range("A1:PE5").Copy Destination:=wkbk.Sheets("DB Output").Range("A1") For Each rCell In wkbk.Sheets("DB Output").UsedRange If InStr(rCell.Formula, ThisWorkbook.Name) > 0 Then

Categories : Excel

CSHTML rendering text only - static page?
It could be that an older version of System.Web.WebPages.dll is loaded to memory, and it tries to cast the your cshtml page to a version of WebPages class from that dll. To test this, try to see what http modules are currently registered: var allModules = HttpContext.Current.ApplicationInstance.Modules; for( int i = 0; i < allModules.Count; i++ ) { Trace(allModules.GetKey(i)); } In my case that was: .... __DynamicModule_System.Web.WebPages.WebPageHttpModule, System.Web.WebPages, Version=, Culture=neutral, PublicKeyToken=31bf3856ad364e35_bca8e05a-5746-45b0-be95-2b920b455ccf __DynamicModule_System.Web.WebPages.WebPageHttpModule, System.Web.WebPages, Version=, Culture=neutral, PublicKeyToken=31bf3856ad364e35_c1a67b42-31a9-47f1-8483-9e712fabe2a7 To fix the problem

Categories : Asp Net

JavaScript get JSON from rest API without re-rendering the page
Remember when calling jsonp apis, you have to add an additional parameter to the url : callback=? here's a simple fiddle as an example: http://jsfiddle.net/8DXxN/

Categories : Javascript

Wordpress stops rendering page after the_content()
This could be a either an open tag (not closed properly), incorrectly closing a tag, or nested comments. Check your source... if the source has all the content there and it's simply not rendered... it's not a wordpress problem but a content problem.

Categories : PHP

Page format falls apart when rendering
There is some unnecessary formatting you've added to the new.html.erb. One of rails' strength is the minimal amount of work created with helpers such as form_for <h1>Books#new</h1> <p>Find me in app/views/books/new.html.erb</p> <% flash.each do |key, value|%> <div class="flash <%= key %>"><%= value %></div> <% end %> <div class="form-horizontal"> <div class="control-group row-fluid form-inline"> <%= form_for @books do |f| %> <%= render 'shared/error_message' %> <%= f.label :title, "Title:"%> <%= f.text_field :title %> <%= f.label :author, "Author:" %> <%= f.text_field :author %> <%= f.l

Categories : HTML

URL Routing not rendering called page correctly
I think you need to provide a little more code for us to be able to completely help, but I have a strong feeling this is your prob: In your first example, you were using a querystring to pass Companies_PKID, so I guess you code behind had something like: if (!String.IsNullOrEmpty(Request.QueryString["Companies_PKID"])) { string blah = (Request.QueryString["Companies_PKID"]).ToString(); } Now you need to get the value differently: if (Page.RouteData.Values["Companies_PKID"] != null) { string blah = Page.RouteData.Values["Companies_PKID"].ToString(); } Note, you'll want to check for both the querystring and the route data. The other thing you'll want to ensure is that the paths to your style sheets, etc, are correct.

Categories : C#

Cross checking with database before rendering page
You want to ask the server to see if the data is valid. Aside from the form data, I would also post a flag telling PHP that this is the AJAX validation so it can tell the AJAX post from normal form submission. In PHP, after the data validity is determined, it can just return true or false. Then your Javascript can determine what to do from that point on. However, I think there are other ways to go about this. Maybe you shouldn't let the user modify these fields, or maybe you can post the form, and render the form again if the user has submitted invalid data. Another alternative is to limit the choices that the user can do, so their input is always valid.

Categories : PHP

Why do inline scripts block rendering when put at the bottom of a page?
In the inline script, the time is taken up running the script, which might change the DOM. Trying to render the DOM while it's mutating is a recipe for a mess. So rendering only happens at points when the JS is stalled, and therefore the DOM is stable. While waiting for an external script to download, the running of scripts is stalled, so the DOM can be rendered safely. The downloaded JS won't be run until the rendering is complete.

Categories : Javascript

Rails Pdf to jpg conversion rendering one image for multiple page pdf
I've always used ImageList to handle multi-page documents like this: def do_parsing pdf_path = "#{Rails.root}/public#{@pdf.pdf.url}" image_list = Magick::ImageList.new(pdf_path) { self.density = 400 } save_pdf_images(raw_pages_arr) end def save_pdf_images(raw_pages_arr) raw_pages_arr.each_with_index do |raw_page, index| page_number = index + 1 image_name = "#{@pdf.form.name}_page_#{page_number}.jpg" raw_page.write(image_name) image = File.new("#{Rails.root}/#{image_name}") build_pdf_image(image, page_number) end end Overall, though, I would recommend using a service for this. There are many intricacies (like color profiles, handling CropBox/BleedBox/ArtBox/TrimBox, alpha channel, etc) of PDF to image conversion and it's a task best left to servic

Categories : Ruby On Rails

Should the goal be an identical page rendering for legacy browsers?
When developing for multiple browsers, you cannot provide an identical experience for every browser. After all, someone could try to access your site via Lynx, and you're clearly not going to design your UX to ensure that someone who is using Lynx will have an identical experience as someone who is using the latest version of Chrome. The first question to be answered is to determine which browsers your users are using. If you have a current version of the application, you can answer this question via log data. If you don't have a current version of the application, you can try to approximate an answer to this question by using general web usage statistics or by surveying representative target users for your application. With this information, you can then make an informed decision a

Categories : Misc

Issue using Trinidad PPR (Partial Page Rendering) with Facelets
Finally, I solved the above problem by calling the function below on load page. // Override function to solve ppr problems function overrideFunc() { TrPage.prototype._updateViewState = function(a59, a60, a61) { var a62 = null; if (a61) a62 = a59.getElementById(a61); for ( var i = 0; i < a59.forms.length; i++) { a62 = a59.forms[i]; if (!a62) return; var a63 = a62.elements[TrPage._VIEW_STATE_ID]; if (!a63) { a63 = a59.createElement("input"); a63.type = 'hidden'; if(_agent.isIE && _agent.version < 8) { a63.id = TrPage._VIEW_STATE_ID; } a63.name = TrPage._VIEW_STATE_ID; a62.appendChild(a63); } a63.value =

Categories : Misc

© Copyright 2017 w3hello.com Publishing Limited. All rights reserved.