1
How can I change the value of the attribute href
of a <link>
and of src
of a <script>
.
Real problem, I have two screens that are at different levels (different folders),
where both are accessed by window.load
which lies within the modal option Open
.
translating, on the first screen I access modal and external css and javascript files are accessed by 2 levels above ../../
and on the second screen are accessed with three levels ../../../
Example:
jQuery:
$("#pesquisaClienteCss").attr("href","../../view/css/pesquisaCliente.css");
html:
<link id="pesquisaClienteCss" href="../../view/css/pesquisaCliente.css" rel="stylesheet" type="text/css" >
I need when I get one $("#pesquisaCliente).dialog("open");
the attr
modify the href
link increasing a folder level ../
have managed to understand?
The paths must begin with
/
to be related to Origen (root). Then it becomes easier to work and you don’t need to../../
. Have you tried that?– Sergio
It doesn’t make much sense to change src from a script tag. The old script is not downloaded from memory, and I don’t even know if the new one would be loaded.
– bfavaretto
It gives me a strong impression of being a XY problem.
– Bacco
I understand Bacco, I’m wanting to talk about the solution instead of the problem, my problem and the following, I have a customer search modal that is accessed by two screens, customers and reports that have different folder levels, it turns out that at the client level the css and javascript links work perfectly, but at the reporting level they are not found, being found only one level above ../../../
– Gabriel Rodrigues
And you can’t just put the respective CSS in the source of each modal?
– Bacco
I don’t understand, can you show me an example ?
– Gabriel Rodrigues
You’d have to see how you’re doing in the practical case, otherwise it’s difficult. Why don’t you edit the question and show relevant excerpts of how the load does in the real case, and how is a modal of these? So the whole community can help. Remember that you know how so things there, and we only know what is written in the question.
– Bacco
Climbing back up the directory tree is usually the path to madness... ;)
– brasofilo