HTML + Javascript - Combining Static URL with document.referrer - javascript

I currently use this code on my "thank you for commenting page" on my blog:
<a style="cursor: pointer;" onclick="location.href = document.referrer;" onmouseover="this.style.cursor='pointer'"> Click here</a>
When someone clicks on the anchor "click here", they are taken back to the page that they were on last. Since this "thank you for commenting page" is only accessible after they have landed on one of my posts and added a comment, there will always be a document referrer (wont ever be blank).
Since this was working nicely, I thought that I could add something like "We really appreciate your comment. If you want to help this blog, please consider sharing the article you have just read on Twitter" (I can include others later).
I want to anchor "Twitter" with the static share URL (http://twitter.com/?status=) with the document.referrer variable. I tried something like this without success:
http://twitter.com/?status=' + 'document.referrer;'">test
Another unsuccessful attempt:
<script>
document.write('test');
</script>
Basically I want the end result to look like this:
http://twitter.com/?status=http://www.myexampleblog.com/category/lastvisitedpost/
I have been fighting with this for a couple hours now but due to my limited coding knowledge, I am struggling. Please can someone help me? I know this could also probably be done with a function or perhaps done a better (or cleaner) way using php but I really just want to use an with javascript if possible.
Thanks in advance :)
Jared

Try This:
document.write('test');

You'll need to test this at least localhost, not as regular files like say on your desktop. I've added an alert to help you out...
1.html
2.html
2.html
Click here

Related

Add javascript to cover page button

I have a button on my cover page and I need to assign to it 1 line of javascript code (namely javascript:languageClicked(0); to work with this neat addon: Multilingualizer) .
So the button should execute that line of code and do its usual job, namely to send the user to my main webpage.
thx in advance
Is the languageClicked function code from Multilingualizer? If so, maybe that addon isn't enabled correctly on your page or something and the js files for it are not being loaded.
But, once they are loaded. You can replace your button with this code:
ENTER
Screenshot
Since you want the user to be redirected to /expnew after activating languageClicked.
Hope this helps! Also, there is one catch though; don't change this unless you know for sure you have those JS libraries loaded. ^_^
Without some HTML snippets and the name of the button you are working with, it is hard to know exactly how to help. However, I can share some general knowledge that may provide the answer for you.
The two most common ways that JavaScript triggers are implemented are:
1. <a> "link buttons":
Your code might look something like:
Click me!
2. <input>/<button>/any element onclick events:
Your code might look something like:
<button onclick="javascript:languageClicked(0)">Click me!</button>

I can't access the javascript expandable menu at this page with jSoup. How can i make it work using Phantom.js or HTML Unit?

I got a problem when parsing this page. I perfectly get the price, the airline, the departure time, etc.
But what i want is the flight number. And its hidden, you need to click in a flight and the menu expands to show it.
Here is where jsoup has to stop. if you click on "view source" anywhere, it won't show e.g. flight "6186". If you expand the menu and rightclick to there, it will give you the flight back.
The specific information I am searching for is this:
So, I noticed I need to use something like a headless browser to access all content. But when trying to understand phantom.js or htmlunit, i got huge problems getting started. I can't formulate what I need and I'm irritated by the features of headless browsers. An example code on how to get this into parseable HTML would be so nice.
Does anyone have experience with parsing elements like these? Thank you so much in advance.
best regards!
UPDATE to answer to jPOs comment. Other help still extremely apreciated - Here is what i see when i inspect the events:
UPDATE 2: Any Ideas on how to do this? Maybe headless browsers?
So as an answer look at this code.
$.ajax({
url:"http://www.kayak.de/s/run/inlineDetails/flight",
type:"post",
dataType:"json",
data:{
localidx:104,
resultid:"ea63237698f20885f47a9b3827f9953b",
searchid:"kUECCUIWzU"
}
});
You can see there is a server waiting for your request. Trying to understand the parameters sent to the server gave me few options, I'm going to stick to these.
localidx is the id written in the button Details anzeigen
resultid is also written inside that button
searchid is written in an iframe with the id master-1 in the name tag
I hope you are a friend with regexes because that's what you have to face :/
Good luck! Hope I helped!

Html/Javascript - How to make an html link display a url, and have it actually be redirected to a javascript function?

I have an html page, and I need a link to show that the user would be going to 'example.html', when really, the link goes to 'javascipt:ajaxLoad(example.html);'.
I tried this:
Example
But it didn't work. Any help? I already asked the webmasters stackexchange, and they told me that this would be a javascript programming question. Not an html question.
Example
By returning false you prevent the default action. And this way the links will still work when javascript is disabled, but then you don't get the AJAX functionality.
Just point the href at the actual file. The javascript onclick will take precedence - as long as you take care to disable the actual click effect by doing a "return false" or similar, the status bar will show 'example.html' and not the javascript url.
As well, note that it should be javascript:... (you're missing an r). The onwhatever attributes are already assumed to be javascript, so you could just say onclick="ajaxLoad(...) anyways.
Look, I'm not sure if I got exactly what you're asking about here, but the following fix often works with me. Just change the double-quotes to single-quotes, and put double-quotes around the example.html part
<a href="example" onclick='javascipt:ajaxLoad("example.html");'>Example</a>

Anyone know of a javascript removal tool for html

I am having issues with an Ebay template, if I try to upload it get's kicked back to me saying that it cannot contain javascript, I'm assuming that it's in the picture rollover option (mouseover pic enlarging tool) Any help would be greatly appreciated, I'm not real Java intuitive.
Just delete anything between the <script> and </script> tags. Or perhaps post the code snippet here so we can tell you what to remove.
The template should have a HTML file inside.
Search for ... parts and remove them as mentioned before.
Search for instances of onmouseover="...", onmouseout="..." and generally anything that looks like , removing the onsomeevent="dosomething" part.

making un-visible a specific part of url generated by javascript + codeigniter

http://www.blabla.com/our_work/client/client-name#/uploads/18.jpg
I use CodeIgniter, and this is the url I have. I use a gallery script at the page, and it generates #/uploads/18.jpg such thing at url :( is there any way to make it unvisible or sth . maybe with htaccess. i dont know.
i dont want to spend an another day finding an another gallery script, im already out of deadline :(
appreciate helps...
Just leave it there. What's the harm? Really. You are on a deadline, and are wasting time trying to remove a #tag from the url.
Can we have a look at the gallery script? perhaps you could edit something there to make it work. That's what I always do with the scripts I use to make them work with CI.
I'm afraid that's how it's supposed to work. the '#' part is an HTML anchor that the script uses to do the switching as far as I know. You might to look for a different script.
you can try to play with window.location in JS erasing the string after hash, but I doubt that would make some sense.

Categories

Resources