I want to display /%25 as my URI. I tried
history.replace("%25");
But for some reason this translates to /%.
I know this isn't a browser issue since this works:
document.location.href = "%25";
How can I set the URI to /%25 with react-router?
"Fixed" it like this:
history.replace(url.replace("%25", "%2525"));
This doesn't work for more than one % though.
Related
Same-page links work by referencing another element that has id="sec-id" on the same page, using
for instance. A link like this is relative.
However, if I use that very same syntax in the iframe in my LaTeX.js playground, it will not just scroll to the destination element, but (re)load the whole playground page inside the ifame. (Note that I set the contents of the iframe programmatically with iframe.srcdoc = html)
Example: LaTeX.js playground, right at the end of the first section click on the link in "See also SecĀtion 11." in the iframe on the right side.
What could be the reason?
UPDATE: I now understand the source of the problem: the browser uses the document's base URL to make all relative URLs absolute (see <base>). The trouble starts with an iframe that has its content set with srcdoc: no unique base URL is specified, and in that case the base URL of the parent frame/document is used--the playground in my case (see the HTML Standard).
Therefore, the question becomes: is there a way to reference the srcdoc iframe in a base URL? or is it possible to make the browser not prepend the base? or to make a base URL that doesn't change the relative #sec-id URLs?
I don't know exactly how you could resolve this, I think it is because the srcdoc, you can't use the src with the content-type because the character limit, but you can convert it to a Blob and it kinda works, the style are lost though. Maybe you can use it as a starting point, based on your page:
// Get the document content
const doc = document.querySelector('iframe').srcdoc;
// Convert it to blob
const blob = new Blob([doc], {type : 'text/html'});
// Load the blob on the src attr
document.querySelector('iframe').src = URL.createObjectURL(blob);
// Remove srcdoc to allow src
document.querySelector('iframe').removeAttribute('srcdoc');
What about catching the event and scrolling to the desired anchor?
$("a").click(function(e) {
$('.iframe').animate({
scrollTop: $(e.target.attr('href')).offset().top
}, 2000);
return false;
});
For the record, it seems that my question is not possible, i.e., it is not possible to use relative same-page links in an iframe that has its content set using srcdoc. A workaround has to be used, see the other answer.
I Have a two anchor tag for look like below
<a href="www.exx.com" target="_blank">
AnnualBudget</a>
When i click the above Anchor tag ,Its not gone correct URL(For it's gone to Mydomainname/www.exx.com). But the same time below anchor tag is working and go to correct url .
<a href="https://www.exx.com" target="_blank">
AnnualBudget</a>
Why www is not worked but https is worked ? And How can i solve this issue ?
Update :
The url is entered from user in textbox .So how can i check it ?
Try putting a "http://" in front.
I.e.
AnnualBudget
"www" is not a protocol/scheme. HTTPS or HTTP are protocols.
Absolute URLs have to have a "scheme" in front, see details about URLs on Wikipedia.
Alternatively, this would also work:
AnnualBudget
Update 1:
Since you comment that your input comes from the user, let me add this one:
(Although this refers to SQL injection, the same would be true for all user input).
Update 2:
To check the input for an absolute URL, do something like:
// Read from user input, e.g. (WebForms syntax!):
string my = MyTextBox.Text.Trim();
// Do some checking (this has be done much more thoroughly in real-life!)
if ( !my.StartsWith("http://") && !my.StartsWith("https://") )
{
my = "http://" + my;
}
// Do something with "my", e.g. (again, WebForms syntax only):
MyHyperLink.NavigateUrl = my;
(Please note that I'm no MVC expert, the above pseudo-code uses WebForms syntax instead)
I am attempting to strip the HTML from an iframe using vbscript. Any decent way to do this? Here is the only suggestion I found online, and it is pulling the HTML from the main page, not the iframe:
pageHTML = ie.document.All("ExternalQuestionIFrame").Document.Body.innerHTML
ExternalQuestionIFrame is the name attribute. No ID tagged.
Perhaps try the iFrame's contentWindow.
Set myFrame = ie.document.getElementByID("ExternalQuestionIFrame")
Set internalContent = myFrame.contentWindow
pageHTML = internalContent.Document.Body.innerHTML
This can probably be cleaned up into a one-liner, but I like to set my objects a little piece at a time.
contentWindow reference: http://www.w3schools.com/jsref/prop_frame_contentwindow.asp
I have a bit different task to do,
first, i have add an iframe tag dynamically, which i was able to do easily using the code->
function getFrame()
{
var iframeTA = document.createElement("IFRAME");
iframeTA.setAttribute("src", "iframeTakeAction.html");
iframeTA.style.width = "200px";
iframeTA.style.height = "200px";
document.getElementById("status").appendChild(iframeTA);
}
now, want i want to do is to access the elements of iframeTA (i.e. elements within the body tag of 'iframeTakeAction.html' which is the source of iframeTA),
something like this ->
iframeTA.body.getSomeElement......
Hope this kind of operation is possible, if so please put some light.
Thanks.
You should be able to access it with:
document.getElementById("TOUR IFRAME ID")
However, this only holds as long as your iframe src is a relative path on the same domain. If you change the domain then your browser will prevent you to do this.
I have footnotes in page as:
footnote.
however if current location of the page is
www.domain.com/?q=something,
the resulting url of footnote is
not www.domain.com/?q=something#footnote,
but www.domain.com/#footnote
so is absolute url usage is the only solution for above, or there some techniques to come over this?
thanks
I just tried that in Chrome and it worked fine. By default, a browser will assume it's a relative URL (unless the format indicates otherwise).
From what you're posting here, I hardly see how it can fail. If you provided some more info, maybe people can help.
But it will happen at IE.
You can try this
jQuery(document).ready(function($) {
$body = (window.opera) ? (document.compatMode == "CSS1Compat" ? $('html') : $('body')) : $('html,body');
$body.animate({scrollTop: jQuery('.youcalss').offset().top}, 1000);
})