make get request on user clicks. (non javascript) - html

I have and link like this (plain html)
<div>
My link
<p>When a user clicks on this "my Link" I need to make a get call to fetch a small image from server for tracking purposes</p>
</div>
The user must be directed to his link location but the fetching of the image from server must be done in background.
I can add something static like this
<img src ="image location for tracker">
but how can i associate it with user clicks.

Without the use of JavaScript I think what you have mentioned would be quite difficult to achieve (but happy to be proved wrong). My question back would be does you hosting allow for any type of simple server side scripting?
If yes, you could make the links point to a simple php or classic asp page which can do the image call or execute the tracking code then redirect the user to the original destination.

Related

WhatsApp HTML Sharing Link for Image

I know you can share messages with and this is working on android and ios now:
Share with whatsapp
However I'd like to share an image trough a button on my website like someone would share an image from his phone (gallery). Is this anyhow possible?
One solution that comes to mind is uploading a photo to your server via AJAX, returning the link to the uploaded photo and then sending a message with the link to your photo using the method you described in your question. This is not quite the same as sending an image directly using Whatsapp since the recipient would only receive a link, but I doubt there will ever be a way to send an image to another application from your gallery using a webpage since that would raise some serious concerns.
Roughly, the process would like this (keep in mind that this will require some testing to get right and find a solution that works well on all platforms or at least most of them):
Create an image upload on your website. Simply having <input type="file" accept="image/*"> on your page should, on most platforms, allow you to create a button which will open a dialog to select an image from your phone's gallery when clicked. You can find a full example here or use a library such as Plupload which contains many upload methods, including HTML5 which is what you need.
Create a simple server-side upload. This depends on your language and platform, but all you need to do is store the image somewhere and return a link to it in response. If you don't want to store these images on your server, you could forward it to Imgur API and upload there.
Redirect the user to the whatsapp:// link that contains the image link.
window.location = 'whatsapp://send?text='+encodeURIComponent(imageURL);
This is the point where you need to do some testing on different platforms, though. You might not be able to redirect to a whatsapp:// link this way (since it seems like a security concern), so you may need to trick it (this is a bad idea, but I'm including it for the sake of completeness; the data-action part is from this answer):
var fakeLink = document.createElement('a');
fakeLink.setAttribute('href', 'whatsapp://send?text='+encodeURIComponent(imageURL));
fakeLink.setAttribute('data-action', 'share/whatsapp/share');
fakeLink.click();
In the end, if neither of these work, your best bet is creating a link once the upload is complete for the user to "confirm" sending which actually contains the above whatsapp:// link in the href field.
There are many factors to test and some that are implementation specific so I had to keep it vague without much code - if you come across anything else when implementing this, please mention it in the comments.

How to add a hyperlink to a password protected area of a website bypassing password login?

I am trying to add a hyperlink to an area of another website requiring login to view files. The target website will be a photo gallery website which then will be accessible on my website.
My question is this. Is it possible to encode login information into a hyperlink therefore bypassing login when hyperlink is clicked? Please let me know your thoughts.
Short answer: Client-side, this would be near-impossible, considering you cannot send form data via a hyperlink (though you can receive it, but then that gets dynamically added to the URL via method POST.) You can do this, however, by using Javascript by using a submit button (if the page doesn't have protection against csrf) which can dynamically inject parameters via a form, but then you would need a POST request cross-domain which is where my point with needing admin access comes in;
If you were to attempt to do this server-side, you would have to have admin access to both sites, certainly not just to site A. From then you can inject parameters into the hyperlinks via server-side scripting languages such as PHP or Python, which would then add the required information to the form upon landing on site B. But you must (must) be careful, this opens up the potential of a serious security compromise depending on how you allow users to log in to your site. Assuming it's yours. Either way, this is still a bad idea, which concludes to my
Shorter answer: No.

Obtaining the URL for a Particular Page in DotNetNuke 7

I have created a page in DNN 7 and added the standard feedback module available at Codeplex to it. Now I want to link to this page using a hyperlink in the middle of another page (not from a menu).
I am able to see the URL for the feedback page via the admin pages and it seems to be consistent. So the obvious way would be to use the HTML module and simply hardcode the URL. But something feels wrong about that. I thought of creating a simple module, encapsulate the hyperlink and surrounding text in a control and use NavigateURL to obtain the URL for the feedback page. Unfortunately, I have not been able to figure out how to do that. I have seen a lot of information about getting the URL for other controls within the same module and even using ModuleID but nothing that would help me implement the code for getting the URL for a particular page at my level of experience.
Sorry about the long intro but I was wondering if it is good practice to hardcode the URL and if not how to programmatically obtain the URL for the feedback page.
TIA
The first argument to NavigateURL is TabId (pages are called tabs in the DNN API). To get the ID of the Feedback tab/page, you'll want to call a method off of the DotNetNuke.Entities.Tabs.TabController class; I'd suggest the static method TabController.GetTabByTabPath(portalId, tabPath, cultureCode), so something like this:
Globals.NavigateURL(TabController.GetTabByTabPath(this.PortalId, "//Feedback", string.Empty))
You're still hard-coding the path to the page here; you could have a setting, which would let you pick the page, but that seems like a bit of overkill for a simple link. The main benefit that you would get by hard-coding the path, but still using NavigateURL is that any changes you make to how URLs are generated (e.g. upgrading to the Advanced URL Provider that comes in DNN 7.1) will happen automatically.
Most folks don't worry much about programatically generating links in HTML content.

HTML Form appearing on button press

I am a newbie to web development so sorry for my stupidity. I am actually creating a local website and I wanted to make a user profile page on that website. What I want to accomplish is that the profile page should be not be editable in the normal use case but when the user presses the Edit button (like in facebook), the fields become editable and a save button appears (basically a form but without reloading the page or any server side work). The user then updates the fields and saves. The save request will be sent to the server to update the database (can that somehow be done without reloading the page too ? i see facebook page does not reload when you edit and save).
So that is it. Waiting for a reply.
P.S. I think some javascript code will come to my rescue.
This is a very general question, so I can't do anything but give a general answer. I would highly recommend you learn jQuery.
jQuery makes it easy to manipulate the HTML and CSS from Javascript - which you'll need to do in order to show/hide the content and the forms for editing the content (or otherwise manipulate the code on the page in order to achieve what you want - there are various ways to do this, adriano's comment on your question lays out a good solution).
The specific part about sending such requests in the background is called AJAX, and jQuery has support for that too.

an iframe for multiple users

I am trying to create a web page with the following :
Buttons and input fields etc. in the top half of the page that allow the user to define certain criteria, when the user clicks submit, the page calls some php code that writes an iframe referenced html file which is then shewn on the bottom part of the web page.
I think I understand how to do this for a web page referring to a single iframe document source but there may be more than one user running the page so how do I have the iframe pointing to the correct iframe source for each user?
Some web searching sugests that this is the kind of thing done with XMLHttpRequest, I'll have a look into that.
If I understand correctly, your PHP code creates an HTML file and then loads it in an iframe.
You could have your PHP script output the HTML, then load the PHP script in your iframe directly. Now there is no way for another user to accidentally get the other users' output.
I'm not sure if I understand exactly what you want to do.. but if you have already existing database of users, make a new table with Iframe preferences... so when they click submit, the preferences will be saved to the database with the user_id.. so next time just check if the user has already chosen... if yes, get the preferences from database.. if not -> redirect him to do so.
I don't know if that's exactly what you want