I want to try and right some code that will guess the default ip of a router that you are currently connected to. To do this, i would write a bit of javascript code that would type into the google chrome URL bar and attempt to search it. For instance: it would type 192.168.0.0 , then 192.168.0.1, etc... currently my largest problem with this is that i have no idea how i would write code that would locate and type into the url bar, i could do it with any other user input. How would i do this?
URL bar is not part of the window so you couldn't just locate it using javascript as with DOM elements.
To read and write to URL you could use window.location (more to find here: https://developer.mozilla.org/en-US/docs/Web/API/Window/location).
If you change window.location to another address, it will force browser to load new content, in the same way as reloading a page. Remember that loading new page will probably lead to discarding your javascript code if it was loaded from within the website.
Another way is to use iframe and dynamically change its url, like here: dynamically set iframe src
If you want to make tool that iterates through possible addresses, i would recommend writing it as a Chrome extension. More about it and tutorial are available here: https://developer.chrome.com/extensions
Related
There are several variations of the question how to replace part of the URL with JavaScript?
but the solutions work for a current url, so first you load a page and then click on the bookmark that stores the javascript code to go to the edited location.
Is there a way to make this a default in Firefox? That is, if I click on a link and that link contains a specific chunk /epdf/ I want that chunk replaced with /pdf/ before loading the page in the first place.
I have created a bookmark that contains the script
javascript:var url = window.location.toString(); window.location = url.replace(/epdf/, 'pdf');
but that has the limitation I described above. Is there a way to perhaps load that script as a plugin on Firefox?
(I am way out of my depth here, not even sure what search terms to use for this)
Update browser address bar without reload
I found this about making the URL change without updating.
I want to make a website like
http://fancytext.blogspot.ie/
but instead of adding the symbols to the text box there I want the symbols to overwrite the URL on the address bar is this possible with javascript or ruby?
You can "push" any text into the address bar using pushState and it's simple like hell:
window.history.pushState({url: yourUrl}, null, yourUrl);
remember:
you could use full address, when you try to push url, other ways the path in url will be appended to current url, when you try to use slashes (if I remember correctly)
Working example is my own site, where address is changing while you scrolling thru page http://dariuszm.pl (may not work on older browsers)
Definitely possible. You simply need to put a hash (#) before your symbol. Anything after the # does not result in a page change.
You can easily set it without JavaScript by the href in an a tag...
Ⓐ
But if you're desperate to use JavaScript, it can be done there as well...
<script>
location.hash = '#Ⓐ';
</script>
I'm using SSRS208R2 to create reports.
I display these reports using a ReportViewer control in my web application.
some of the fields in my table are tags that user javascript:void window.open...
to opent a link in a new window.
I use Jump to URL action for my placeholders to achieve that.
The Problem:
My report is displayed in a separate domain.
ReportViewer Control renders the tags with target='_top' property.
IE will not let any href='javascript:void alert....' action to run from a different domain Iframe if the target is _top.
Questions:
is there a way to define a different target for an anchor tag - i have search some places and found that the SSRS web application can use rc:LinkTarget=_Blank to chage all the targets but that dosent seem to work for me. are there any other possible solutions?
Can anyone suggest a different approach to open a link in a new window that will not hit a wall when the report is displayed from an Iframe on a different domain ?
Solved!
I tried the query string "rc:LinkTarget" at the built in reporting services web interface..
and that did not work for me initially.
Then I tried to changed the location of that parameter and it worked.. I really don't think that that was it maybe there was a spelling error or something, anyway...
So I did some more digging and found that the report viewer control has the same property called LinkTarget I used it to define an empty string and everything works fine.
Cheers...
So I have this js code for an image gallery:
(this.settings.update_window_hash) {
var thumb_link = this.images[this.current_index].thumb_link;
if (thumb_link.attr("id")) {
window.location.hash = "#image-"+ thumb_link.attr("id"); //#url
} else {
window.location.hash = "#image-"+ this.current_index;
};
};
So as you've probably assumed this appends $image-(int) to the url. So if I have a
gallery with multiple images if the thir image is selected the url will look like this:
mysite.com/gallery.html#image-3
All good. But I dont really like this to be appended to the end of the url. So is there
any problem if I remove this part of the script entirely? So regardless the number of
image currently selected the url will look like this:
mysite.com/gallery.html
I've tested it and it works okay. But I'm not very experienced with javascript and I want
to make sure I'm not making a mistake. So
IS IT OKAY IF I REMOVE THIS SCRIPT ENTIRELY? WILL IT CAUSE ANY PROBLEMS?
HUGE THANKS.
Hashes at the end of the URL are optional and not required so YES, you can remove that script if you want (I'm not sure what problem you're trying to solve by removing it). In general, you get more useful answers if you tell us what problem you're trying to solve rather than what solution you're trying to use.
Hashes are used when you want the URL of the page to direct the viewer to some subcontent on that page. If you remove them, your page will still work just fine, but the URL of the page will not reflect which image is displaying. So, if the viewer saves that URL and comes back to it or links to it or anything that keeps a reference to the URL, it will go to the generic version of the page, not the onethat shows a specific image. Whether that is OK is totally up to you and how your page works.
Just use:
location.replace(location.href + "#myhash");
The location.replace method overwrites the current step in browser history. For an example of this in action see http://prettydiff.com/slideshow/
The stuff after the octothorpe normally represents a "name" or "id" from the web page. You can have an anchor tag (<a name='thevalue'>) and the browser will interpret the text after the octothorpe (http://example.com#thevalue) by scrolling to the associated section on the page.
Unless the page has special JavaScript to behave differently. In your case, it depends upon the full functionality of the web page you're writing. If you have smoke tests/unit test/use case tests/other QE tests, you should execute those to ensure that your changes don't break anything.
See http://www.w3schools.com/html/html_links.asp for more description of the standard usage.
I have a website that is 1 html file and uses javascript to hide tabbed pages.
The url gets rewritten with a # for the different pages to make them bookmark-able.
Is there a way to make the different pages show in search engine results? It would be good to have them show up as different pages there.
I have read the below doc, but I think that is just for dynamically generated ajax content, right?
http://code.google.com/web/ajaxcrawling/docs/getting-started.html
I read the page mentioned by you. That is for Ajax site. In your case it is not Ajax.
Another point as Jeff B has mentioned is that the chance is high that Google will index all content for each trick you use. In that case it would be bad as Google will get duplicate content. It will be not very bad as all content are from your site only.
Search Engine questions like this are very tricky and difficult to answer as no one know the exact functioning of Search Engine.
In my thinking you either recreate your pages as Ajax and follow the points mentioned in article you got. Or
Use a link for each tag with param. like page1.php?cat1, page1.php?cat2, etc.
and that only load content related to specific tag at a time.
The second solution is no different than implementing different page for each tab, but it can be easier to update in your case! and also all content are still accessible by both person and search engine at a place. Slowly search engine will index your each page with parameter. Remember, It is generally said that Google does not index pages with parameter but it is not true. Google does not index page with variable or id kind of parameter only. They index each page with popular parameters if page content changes.
Still your question is tricky and my suggestion is what comes to me after thinking much about it.
The problem seems to be that even if the different pages were indexed, they would all index the same content. This is because according to your explanation all of the content (including hidden) exists at load time.
If your tabs are links, you simply need to put the href in the link. Google should follow this link, while javascript-enabled browsers will execute your tab-switching code and not follow the link (if you coded it right).
However, the problem of all content being indexed for all pages still remains.
Modify your system like this:
Every link that changes the content of the current tab should have
as href attribute a subpage that contains the content of the tab
intended to appear -> this will be cached by Search Engines.
Those links should have binded JS actions that changes the content
of the current tab and also denies the redirecting that should have
been done by what's in the "href" attribute -> this will be shown to
the user